center map on x,y coordinates

Elisabeth Nolz e9625730 at STUD3.TUWIEN.AC.AT
Sat Oct 2 17:01:38 EDT 2004


dear jan,

thanks for your help. you were right, there were some problems in my mapfile.
now the map can be displayed with
"http://localhost/cgi-bin/mapserv?map=map.map&mode=map". but unfortunately it
can't be centered with "..&mode=map&mapxy=339989.20+1646.20&scale=20000".

your hint to center the map by changing the extent sounds good, but i need to
do it with this link, because the coordinates are a result of a
database-query. the variables are passed through this link.

perhaps someone knows how i could do this.

thx,
elisabeth.


Jan Hartmann <j.l.h.hartmann at UVA.NL> schrieb:

Elisabeth,

There are several reasons why this MapFile cannot work with this URL:

- The layer's STATUS is ON, which means that it has to be added to the
URL to be visible ("http:?/..&layer=strasse). Only layers with STATUS
DEFAULT are always displayed.

- the EXTENT is wrong. EXTENT should be set as "x1 y1 x2 y2", where x2
and y2 are both higher than x1/y1. Your y2 is smaller than y1.

- the MAPXY parameter seems to have switched x/y compared with the EXTENT.

- You give a scale of 20000 in the URL, but you limit the layer between
scales 500 and 1000. This means the layer will not be displayed.

- The expression in the CLASS statement will only select streets with an
ID of exactly *one* letter. If you want to select all streets, the
expression has to be /.*/

- Are you sure your streets are polygons?

Perhaps you could start with a rudimentary MapFile: set STATUS DEFAULT,
comment out MAXSCALE and MINSCALE and set the CLASS expression to /.*/.
Then call this with only "map=map.map&mode=map" in the URL. If you still
don't see anything, check if the extent of the vector file matches that
of the MapFile and if its type is polygon. (e.g. by using ogrinfo). Also
try giving the complete path to the shapefile (as specified here it
should be: /..../cgi-bin/data/vector/strasse.shp).

As soon as you can see a picture of the whole map, you can try to center
it on a given coordinate. My way would be to recompute the extent. Say,
you want a map centered around 1500/337000. A 200*200m map around this
point can ge generated by an extent of 1400 336900 1600 337100. In my
experience this is much easier to compute than MAPXY and SCALE.

Hope this helps,

Jan



More information about the mapserver-users mailing list