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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.