[mapserver-users] plz help

Steve Lime Steve.Lime at dnr.state.mn.us
Thu Jan 22 09:09:11 EST 2009


Amiya: There are a couple of ways to do it, here's the pseudo code. This
assumes you have the two points in variables $x1, $y1 and $x2, $y2:

Option 1 - Build the line using points, lines and shapes

$shape = new shapeObj(MS_SHAPE_LINE);
$line = new lineObj();

$point = new pointObj($x1, y1);
$line->add($point);
$point->{x} = $x2;
$point->{y} = $y2;
$line->add($point);
$shape->add($line);

Option 2 - Use WKT (the easy way)

$shape = new mapscript::shapeObj(MS_SHAPE_LINE);
$shape->fromWKT("LINESTRING($x1 $y1,$x2 $y2)");

Now you need to draw it. Generally you'd have a LAYER defined to draw the line which
would work like so:

$layer = $map->getLayerByName('the_line_drawing_layer');
$layer->addFeature($shape);

$map->draw();
etc...

Steve

>>> Amiya Patra <amiyapatra188 at gmail.com> 01/22/09 7:54 AM >>>
hi

still I am not getting how to connect two points which are already placed in
map , by drawing a line. It is mandatory in my project through php
mapscript. plz help me soon....

thank u........



More information about the mapserver-users mailing list