Quantcast
Channel: Google Map Api v3 and XML feed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Google Map Api v3 and XML feed

$
0
0

I have a XML file like this :

<datas><title>AAA</title><lat>111</lat><lng>5454</lng></datas><datas><title>BBB</title><lat>112121</lat><lng>544254</lng></datas>

....

Example :Here is a "real" example :

<productFeed><Deal><Deal_ID>201090531</Deal_ID><Price>9.50</Price><Destination_Name>Green River</Destination_Name><Latitude>38.989869999999996</Latitude><Longitude>-110.13261</Longitude><Country_Name>United States of America</Country_Name></Deal></productFeed>

The initialize function :

function initialize() {  var myOptions = {    zoom: 7,    center: new google.maps.LatLng(35.82672127366604,-118.916015625),    mapTypeId: google.maps.MapTypeId.ROADMAP  }  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);  downloadUrl("test.xml", function(doc) {      var xmlDoc = xmlParse(doc);      var markers = xmlDoc.documentElement.getElementsByTagName("Deal");      for (var i = 0; i < markers.length; i++) {        var lat = parseFloat(markers[i].getAttribute("Latitude"));        var lng = parseFloat(markers[i].getAttribute("Longitude"));        var latlng = new google.maps.LatLng(lat,lng);        var html = markers[i].getAttribute("Deal_ID");        var label = markers[i].getAttribute("Price");        var marker = createMarker(latlng,label,html);        }      });    }

Is Google Map API able to read it and display it on a map ?If so, how ?

I tried adapt this https://developers.google.com/maps/documentation/javascript/layers?hl=en but does not work.

Thanks for your help.Dominique


Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>