Note that there are some explanatory texts on larger screens.

plurals
  1. POUse xmlhttp data for Google Maps api v3 polyline
    primarykey
    data
    text
    <p>I use an xmlhttprequest to get coordinates out of a mysql database. This works with the following code:</p> <pre><code>var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","http://skyline-va.de/phpvms/lib/skins/crystal/mysql.php?id="+this.flightdetails.id,true); xmlhttp.send(); </code></pre> <p>Looking at the firebug console I see that this outputs the data in this format</p> <pre><code>new google.maps.LatLng(51.2848358165405, 6.77062893232108), new google.maps.LatLng(51.2848358165405, 6.77062893232108), new google.maps.LatLng(51.2848358165405, 6.77062893232108), new google.maps.LatLng(51.2848358165405, 6.77062893232108), </code></pre> <p>and so on.<br> But how can I use this to display a polyline in Google Maps api? I've already tried searching google, unfortunately I couldn't find anything useful. I've also tried several things without success.</p> <p>Thanks!</p> <p>EDIT: Here is the map I am working on right now: <a href="http://skyline-va.de/phpvms/index.php/acars/viewmapbig" rel="nofollow">http://skyline-va.de/phpvms/index.php/acars/viewmapbig</a><br> Basically what I want to do is if you click on one of the planes, the flightpath should be displayed as well. I have the coordinates stored in a database but I have to do the query after the plane is clicked.</p> <p>EDIT2: I managed to output the data in xml format with the google documentary. But I can't get the code to work supplied by Google to display the data. I want to add every new point that comes through the for command to an array.</p> <pre><code> function downloadUrl(url,callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.open('GET', url, true); request.send(null); } var flightPlanCoordinates = [ ]; downloadUrl("http://skyline-va.de/phpvms/lib/skins/crystal/output-xml.php?id="+this.flightdetails.id, function(data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i &lt; markers.length; i++) { flightPlanCoordinates.push(new google.maps.LatLng( parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")))); }; }); flightPath2 = new google.maps.Polyline({ path: flightPlanCoordinates, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2 }); flightPath2.setMap(map); </code></pre> <p>But that doesn't seem to work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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