[mapserver-users] MapServer/MapScript neophite querstion

Daniel Berstein daniel.berstein at dmapas.com
Wed Oct 30 14:04:59 EST 2002


Hi, I'm brand new to MapServer.

I got MapServer up and running with SHP files in less than 15 minutes. Now 
I need a way to integrate information from a MySQL database, which has 
"Lat", "Lon", "Text" and "Angle" columns.

Can someone please share a PHP Mapscript code snippet that dynamically 
creates a layer, and populates the map image with rows from the above table 
(insertion point at "Lat"/"Lon" with text "Text" at angle "Angle"). I would 
optimize the query for elements that fit into the current extent. Example:

<?php
$sql = sprintf("SELECT lat, lon, text, angle FROM geodata WHERE lat BETWEEN 
%.8f AND %.8f AND lon BETWEEN %.8f AND %.8f", $min_lat, $max_lat, $min_lon, 
$max_lon);
$result = mysql_query($sql, $db) or die("Query error");

$map = ms_newMapObj($map_path);

$layer = <what should I put here>

while ($row = mysql_fetch_object($result)) {
	<how to draw create queried items>
}
$image = $map->draw();

$image_url = $image->saveWebImage(MS_PNG,1,1,0);

?>

TIA.

Regards,

Daniel Berstein Z.
Jefe de Proyectos, dmapas.com
Eduardo Hyatt 583, Providencia, Santiago CHILE
*(56) (2) 222 22 60





More information about the mapserver-users mailing list