views:

72

answers:

1

Hi,

I have some problems making a google map that loads XML file that have addresses instead of latlng. XML file holds about 10 records. I can not figure out how to do this.

    $(document).ready(function(){

    var refreshId = setInterval(function(){

        var latlng = new google.maps.LatLng(18.156291402835436, 22.2802734375);
        var myOptions = {
          zoom: 3,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.TERRAIN
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);

        var georssLayer = new google.maps.KmlLayer("data.xml");

            var geocoder = new google.maps.Geocoder();
           //????
            georssLayer.setMap(map);

        }, 10000);
  });



<div id="map_canvas" style="width:99%; height:99%"></div>

help plz

A: 

OK my solution after 2 days:

load the XML with ajax and loop the document for address, then after

map = new google.maps.Map()

address is the address from xml, should have street, city, country

geocoder.geocode({ 'address': address }, function (results, status) {

    if (status == google.maps.GeocoderStatus.OK) {
       //Make the latitude*longitude format
       var latlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
       //Show me the mony!!!
       var marker = new google.maps.Marker({
           map: map,
           position: latlng,
           title: address
       });


       google.maps.event.addListener(marker, 'click', function() {
           infowindow.setContent(html);
           infowindow.open(map,marker);
       });
       google.maps.event.trigger(marker, 'click');
   }
   });
Dr Casper Black