displaying multiple points from database using phpmapscript

Camden Daily cdaily at GMAIL.COM
Thu Jun 2 13:08:24 EDT 2005


Here's the function I use:

function add_point_to_layer($layer, $longitude, $latitude) {
  // create and initialize new point object
  $point = ms_newPointObj();
  $point->setXY($longitude, $latitude);
  // create and initialize new line object
  $line = ms_newLineObj();
  $line->add($point);
  // create and initialize new shape object
  $shape = ms_newShapeObj(MS_SHAPE_POINT);
  $shape->add($line);
  // add our shape
  $layer->addFeature($shape);
}

In your code, you might use it like this:

$layer = $map->getLayerByName('POINTLOC');
for ($j=0; $j < mysql_num_rows($reStation); $j++) {
   $row = mysql_fetch_assoc($reStation);
   add_point_to_layer($layer, $row["x"], $row["y"])
}
$url = $img->saveWebImage();

That code works if the points are already in geographic (long/lat)
coordinates.  You'll have to play with things a bit since yours are in
pixel coordinates, but that at least shows how to use the addFeature
to add points to your map.

-Camden Daily
Prudential Preferred Properties
http://www.prupref.com



More information about the mapserver-users mailing list