AW: [Mapserver-users] Setting the scale of the map
Robert Fritz
robert-fritz at web.de
Sun Jul 27 04:28:08 PDT 2003
Dear Zoltan,
if you want to set the scale you have to calculate the new mapextent and
send the values to the mapserver. I tried it and it seems to work, if you
use a quadratic map.
It does not work correctly, if the map is not quadratic, obviously a error
in the my algorithm.
Maybe you can use the approach:
javascript:
--------------------------------------------------Schnipp
function scale()
{
/*
Formel:
md = (width-1)/(MS_PPI*inchesPerUnits[units]);
gd = extent.maxx-extent-minx;
scale = gd/md;
width = Map-Width in Pixel;
MS_PPI = 72
IpU = 39.3701 fur Meter
--> for more information on this take a look
at the mapserver-mailing list archive.
*/
// Wie gro? ist das Bild in Pixel?
// map-size in pixel, if you use a constant map size you
// take these values, otherwise:
imgObject= parent.map.window.document.getElementById("mapimg");
map_Width=imgObject.width;
map_Height=imgObject.height;
// Wie gro? ist der Ausschnitt in GK Einheiten?
// map-size in coordinate-units:
// (the value is returned by the mapserver)
map_extent = parent.map.window.document.mapform.imgext.value;
//alert(map_Width+" "+map_Height+" "+map_extent);
map_extent_Array = map_extent.split(" ");
L = parseInt(map_extent_Array[0]);
D = parseInt(map_extent_Array[1]);
R = parseInt(map_extent_Array[2]);
T = parseInt(map_extent_Array[3]);
//alert("GD extentmaxx-minx" + (R-L));
// Bildmittelpunkt in Koordinaten
// calculate the center-cordinates of the map
C_X = (R-L)/2;
C_Y = (D-T)/2;
Center_X = (L+C_X);
Center_Y = (T+C_Y);
//alert(Center_X+" "+Center_Y);
// Den Wert berechnen, calculate the new value:
// window.document.form_scale.scale_value.value = the User's Input
theValue = (map_Width) / (72 * 39.3701) *
window.document.form_scale.scale_value.value;
//alert(theValue);
// Den Wert dem Mittelpunkt zurechnen um neuen Extent zu erhalten
// calculate the new Extent
nL = Center_X - (theValue/2);
nR = Center_X + (theValue/2);
nD = Center_Y - (theValue/2);
nT = Center_Y + (theValue/2);
//alert(nL+" "+nD+" "+nR+" "+nT);
// set the new Extent :
parent.map.window.document.mapform.mapext.value = nL+" "+nD+" "+nR+" "+nT;
setTool("Pan");
.......
parent.map.window.document.mapform.submit();
}
--------------------------------------------------Schnapp
Robert
-----Ursprungliche Nachricht-----
Von: mapserver-users-admin at lists.gis.umn.edu
[mailto:mapserver-users-admin at lists.gis.umn.edu]Im Auftrag von Siki
Zoltan
Gesendet: Samstag, 26. Juli 2003 15:52
An: mapserver-users at lists.gis.umn.edu
Betreff: [Mapserver-users] Setting the scale of the map
Hi!
I try to create a html template where the user can set the scale of the
map. I added a textbox to the template
<input type="text" name="scale" value="[scale]">
but i failed to set extension of the generated map.
Does the mapserver use scale cgi variable as input/output or output only?
What other cgi variables can i use to set a given scale? mapext? imgext?
Any idea to work around?
Thanx
--
Zoltan Siki
Tel:+36 1 463 1146 +36 70 3199092 Fax:+36 1 463 3209
Mail: siki at agt.bme.hu
----------------------------------------------------------------------------
---
Assistant professor at egyetemi adjunktus
Department of Geodesy and Surveying Altalanos es Felsogeodezia
tanszek
Budapest University of Technology Hungary Budapesti Muszaki Gazd. Tud.
Egyetem
----------------------------------------------------------------------------
---
More information about the MapServer-users
mailing list