drawing points from mysql with php/mapscript

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Mon Dec 5 09:38:54 PST 2005


Mark,

In your code snippet you have (lat,lon) == (x,y) this is wrong, x=lon 
and y=lat. Make that change and see if it helps.

-Steve W.

Mark Brooks wrote:
> I'm trying to draw points from a MySQL database onto a map with 
> PHP/Mapscript.  I found no clear examples online and so far have had 
> little luck at being successful.  Does anyone out there have any 
> examples you could share?
> 
> Here is part of my mapfile, which sets up an empty layer for the sites I 
> want to draw on the map....
> LAYER
>     NAME sites
>     TYPE POINT
>     STATUS DEFAULT
>     CLASS
>        NAME 'Project Sites'
>        COLOR 150 150 150
>        SYMBOL 'circle'
>        SIZE 10
>        LABEL
>           TYPE truetype
>           FONT "arial"
>           SIZE 10
>           POSITION UC
>           COLOR 150 150 150
>        END
>     END
> END
> 
> 
> And a watered-down snippet from my php code to draw the dynamic points 
> from mysql:
> 
> $image = $map->draw();
> $this_layer = $map->getLayerByName('sites');
> $this_layer->set('status', MS_ON);
> //query database for points
> $query = "select bla bla";
> $sresult = mysql_query($query);
> // loop through database results, adding the new point to the layer
> while ($site = mysql_fetch_assoc($sresult)){
>     $mypoint = ms_newPointObj();
>     $mypoint->setXY($site['lat'],$site['lon']);
>     $mypoint->draw($map,$this_layer,$image,0,$site['name']);        }
> 
> 
> My site points are latitude,longitude.  When I do all this, I only get 
> ONE point drawn on my map.  There are dozens of points but only one gets 
> plotted, and I'm not entirely certain that it truly is a point from my 
> database.  I even hardcoded several different coordinates but only one 
> dot appears on my map.
> 
> What am I missing?
> 
> 



More information about the MapServer-users mailing list