문제

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.

도움이 되었습니까?

해결책

As the comment above was the actual solution

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top