Note that there are some explanatory texts on larger screens.

plurals
  1. POJS: How to make a dynamic Google Maps Polyline?
    primarykey
    data
    text
    <p>I am working on a Google Map which needs to show: a KML (floor-plan) a Polyline which should take its coordinates from a GET response, each 5 seconds. I would like the polyline to update itself with the new coordinates that arrives from the RESTful API. This is the code [updated]:</p> <pre><code> var FlightPath1 = [] $(document).ready(function() { var BASE_URL = "https://its.navizon.com/api/v1/sites/" //Do not change this SITE_ID = "1001" // Your site ID here MAC_add = "00:1E:8F:92:D0:56" //Mac address of the device to track USERNAME = "demo@navizon.com" // Your username PASSWORD = "" // Your password var Path1=new google.maps.Polyline({ path:FlightPath1, strokeColor:"#F020FF", strokeOpacity:0.8, strokeWeight:2 }); // Send the request jQuery.support.cors = true; // Enable cross-site scripting function makeCall() { $.ajax({ type: "GET", url: BASE_URL + SITE_ID + "/stations/" + MAC_add + "/", beforeSend: function(jqXHR) { jqXHR.setRequestHeader("Authorization", "Basic " + Base64.encode(USERNAME + ":" + PASSWORD)); }, success: function(jimmi) { // Output the results if (typeof jimmi === "string") { jimmi = JSON.parse(jimmi); } //Display the results FlightPath1.push("new google.maps.LatLng(" + jimmi.loc.lat + "," + jimmi.loc.lng + "),"); var mapOptions = { zoom: 19, center: new google.maps.LatLng(jimmi.loc.lat,jimmi.loc.lng), mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var SanDiegoKML = new google.maps.KmlLayer({ url: 'https://s3.amazonaws.com/navizon.its.fp/1001/05w0kyw829_a.kml' }); SanDiegoKML.setMap(map); google.maps.event.addDomListener(window, 'load', jimmi); }, error: function(jqXHR, textStatus, errorThrown) { alert('Error'); } }); window.setTimeout(makeCall, 5000); //run the script each 5000 milliseconds } makeCall(); }) </code></pre> <p>But I nothing happens. And I get no errors neither. Could some one help me? Thanks..</p>
    singulars
    1. This table or related slice is empty.
    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.
    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