Question

I am getting the latitude/longitude from the DB. I am unable to draw a line between two distances. Here is my code

var auto_refresh = setInterval(
function () {
    $.get('http://developer.allsecure.me/Location/longlat', function (data) {
        map_canvas.setCenter(new google.maps.LatLng(data.startlat, data.startlong));

        clearMarkers();

        setMarker(map_canvas, 'center', new google.maps.LatLng(data.startlat, data.startlong), '', '/img/device.png', '', '', true);

        var line = new google.maps.Polyline({
            path: [new google.maps.LatLng(data.startlat, data.startlong), new google.maps.LatLng(data.endlat, data.endlong)],
            strokeColor: "#FF0000",
            strokeOpacity: 1.0,
            strokeWeight: 10,
            map: map
        });
    }, 'json');

}, 1000);

I don't know why it isn't adding the polylines between the two distances.

Was it helpful?

Solution

As the comment above was the actual solution

When you define the line you use map: map shouldn't this be map: map_canvas?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top