Note that there are some explanatory texts on larger screens.

plurals
  1. POGet DATA from xml google maps
    text
    copied!<p>I get data from Google Maps in XML format. All functions are working, but I have little problem. It only shows me the last data. Why is that, and how can I solve it?</p> <p>This is my code (<a href="http://jsfiddle.net/PHcvk/" rel="nofollow">jsFiddle</a>)</p> <pre><code>function getline() { downloadUrl("line.php", function(doc) { var g = google.maps; var xmlDoc = xmlParse(doc); bounds = new google.maps.LatLngBounds(); // ========= Now process the polylines =========== var lines = xmlDoc.documentElement.getElementsByTagName("line"); // read each line for (var a = 0; a &lt; lines.length; a++) { // get any line attributes var colour = lines[a].getAttribute("colour"); var width = parseFloat(lines[a].getAttribute("width")); var diameter = lines[a].getAttribute("diameter"); var project = lines[a].getAttribute("projectid"); var contract = lines[a].getAttribute("contract"); var comp = lines[a].getAttribute("complated"); var id = lines[a].getAttribute("id_line"); // read each point on that line var points = lines[a].getElementsByTagName("point"); var pts = []; var length = 0; var point = null; for (var i = 0; i &lt; points.length; i++) { pts[i] = new g.LatLng(parseFloat(points[i].getAttribute("lng")), parseFloat(points[i].getAttribute("lat"))); if (i &gt; 0) { length += pts[i-1].distanceFrom(pts[i]); if (isNaN(length)) { alert("["+i+"] length="+length+" segment="+pts[i-1].distanceFrom(pts[i])) }; } bounds.extend(pts[i]); point = pts[parseInt(i/2)]; var info = "&lt;b&gt; Contract: &lt;/b&gt;" + contract + " &lt;br/&gt; &lt;b&gt;Project: &lt;/b&gt;" + project +"&lt;br/&gt; &lt;b&gt;Diameter: &lt;/b&gt;" + diameter + " &lt;br/&gt; &lt;b&gt;Complated: &lt;/b&gt;" + comp + " &lt;hr&gt;&lt;br/&gt;&lt;a class=\"inline-link-1\" href=\"#\"&gt;Change Data&lt;/a&gt; &lt;a class=\"inline-link-1\" href=\"#\"&gt;Edit&lt;/a&gt; &gt;" + id +"" ; } // length *= 0.000621371192; // miles/meter if (comp &lt; 1) { colorr = '#FA0505' } if (comp &gt; 0 &amp;&amp; comp &lt; 25 ) { colorr = '#FFA640' } if (comp &gt; 24 &amp;&amp; comp &lt; 50) { colorr = '#FFFD91' } if (comp &gt; 49 &amp;&amp; comp &lt; 75) { colorr = '#E8E400' } if (comp &gt; 74 &amp;&amp; comp &lt; 100) { colorr = '#BFFFAD' } if (comp == 100) { colorr = '#0F8500' } var polyline = new g.Polyline({ map:map, path:pts, strokeColor:colorr, strokeWeight:width, clickable: true }); //createClickablePolyline(polyloine, html, label, point, length); // map.addOverlay(polyline); google.maps.event.addListener(polyline,'mouseover', function() { this.setOptions({strokeColor: '#690469' }); this.setOptions({strokeOpacity: 1.0 }); this.setOptions({strokeWeight: 4 }); }); google.maps.event.addListener(polyline,'mouseout', function() { this.setOptions({strokeColor: colorr }); this.setOptions({strokeOpacity: 1.0 }); this.setOptions({strokeWeight: 4 }); }); var mpenc = new google.maps.InfoWindow(); google.maps.event.addListener(polyline,'click', function(event) { mpenc.setContent(info, this); mpenc.setPosition(event.latLng, this); mpenc.open(map); }); } map.fitBounds(bounds); }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload