Display map with specified point in cen ter
Eric Bridger
eric at GOMOOS.ORG
Thu Dec 16 06:46:08 PST 2004
On Thu, 2004-12-16 at 07:47, Miroslav Šulc wrote:
> Thank you, James,
>
> does anybody know whether this can also be done through php mapscript?
>
> Shanton, James A wrote:
>
> >Miroslav,
> >
> >I'm doing it this way.
> >
> >http://www.mydomain.com/mapserver/bin/mapserv.exe?map=D%3A%5CMAPS%5CGIS2%5Ct
> >hex.map&mapxy=" & rst("LONGITUDE") & "+" & rst("LATITUDE") &
> >"&layer=idogr&layer14=railroad&layer14=ortho&scale=5000&mapsize=600+500
Yes this can be done with Mapscript. Unfortunately I'm not sure of the
PHP syntax, but here is a Perl Mapscript example. The trick here is
getting an image object and doing the drawing yourself using
pointObj->draw().
my $map = new mapscript::mapObj("simple_points.map");
# create an image for drawing.
my $img = $map->draw();
my $layerObj = $map->getLayerByName('points');
my $point = new mapscript::pointObj();
$point->{x} = $longitude;
$point->{y} = $latitude;
my $label = "The label";
$point->draw($map, $layerObj, $img, undef, $label);
# To display labels.
$map->drawLabelCache($img);
$img->save("/tmp/map.png");
############### Map file fragment
LAYER
NAME "points"
TYPE POINT
STATUS ON
TOLERANCE 10
# Need fake template for querys to work
TEMPLATE "bogus.html"
CLASS
NAME "buoy"
STYLE
SYMBOL "circle"
SIZE 10
COLOR 255 0 0
OUTLINECOLOR 0 0 0
END
LABEL
COLOR 255 0 0
TYPE BITMAP
SIZE MEDIUM
POSITION AUTO
PARTIALS FALSE
BUFFER 2
END # end of label
END
PROJECTION
"proj=latlong"
END
END
More information about the MapServer-users
mailing list