Jump to content

Update a Google Map


wemustdesign

Recommended Posts

I have a Google map that has a number of points plotted on it, these are taken from the database. I want the user to be able to click a link and this will update the map to show only specific markers. For example I if the user clicked on 'Sweet Shops' all of the other markerw would be removed and only the sweet shop markers would be shown.

 

Below is the code I have written to output the markers. The part in bold is what I need to update and I want this to be done without refreshing the page.

 

Can anyone point me in the direction of what I should be looking at accomplish this. I have looked for tutorials on this but haven't found anything. If anyone could recommend a good site or tutorial on updating a query with mysql I would be very grateful.

 

 

   <?
  //Get locations from database
  	$sql = "SELECT * FROM location [b]WHERE type = 'sweet shops'[/b]"; 
	$result = mysql_query($sql) or die(mysql_error());  
	$rows = mysql_num_rows($result);

	$i=0;
	while ($i < $rows) {
	$id=mysql_result($result,$i,"id");
	$name=mysql_result($result,$i,"name");
	$lon=mysql_result($result,$i,"lon");
	$lat=mysql_result($result,$i,"lat");

//Create markers for locations
  echo " var point = new GLatLng($lon,$lat);\n";
      echo "var marker = createMarker(point,'$name');\n";
      echo "map.addOverlay(marker);";
  $i++;
}
  ?>

Link to comment
https://forums.phpfreaks.com/topic/213720-update-a-google-map/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.