Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Google Map api refresh multiple address lookup

Status
Not open for further replies.

unslog

Technical User
Jan 25, 2009
25
0
0
GB
Hi

using this code to lookup and plot multiple address stored in xml file.
The code works fine , however I want the code to recheck the xml file every 10mins automatically , to plot any need addresses in the dynamic xml file.

I tried a javascript refresh and meta refresh, but couldn't get it to work, it wasn't plotting any new points added to the the xml file. Also , if you load this page and latecr press f5 , it doesn't seem to check the XML file again, thus not plotting any new markers on the googlemap.


My goal is for this page to appear on a dedicated lcd screen , to provide users with new points on the googlemap automatically.

Here is the code;


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>

<script src="[URL unfurl="true"]http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAAAODEAUQU8wE0P-pBf2iQRTnzsFwIeCu34dhd7k1YgvvrV0V_BTw7VjoNLKim07K28mrYltEycKV4w"[/URL] type="text/javascript"></script>

    <script type="text/javascript">

    var map;
	var geocoder;
   	var xml;
   	var markers;
   	var address;
 
   // On page load, call this function
   function load()
   {
      // Create new map object
      map = new GMap2(document.getElementById("map"));  
 
	   // Set map center location	  
	  map.setCenter(new GLatLng(52.406986, -1.507768), 7);
	  
	  
	   // Add Map Controls
       map.addControl(new GSmallMapControl());
       map.addControl(new GMapTypeControl());
	   
      // Create new geocoding object
      geocoder = new GClientGeocoder();
	  
  	  // Download the data in data.xml and load it on the map.
	   
	   GDownloadUrl("./data.xml", function(data) {
          xml = GXml.parse(data);
          markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            address = markers[i].getAttribute("address");           
           geocoder.getLocations(address, addToMap);}
        });

   
   }
   // This function adds the point to the map

   function addToMap(response)
   {
      // Retrieve the object
      place = response.Placemark[0];

      // Retrieve the latitude and longitude
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);
    
      // Create a marker
      marker = new GMarker(point);

      // Add the marker to map
      map.addOverlay(marker);

  	   GDownloadUrl("./data.xml", function(data) {
          xml = GXml.parse(data);
          markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            address = markers[i].getAttribute("address");           
           geocoder.getLocations(address, addToMap);}
        });
		
		
   }

    </script>
   
</head>
  <body onload="load()" onunload="GUnload()">
   <div id="map" style="width: 1020px; height: 700px"></div>
  </body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top