2017-12-18 2 views
-1

Google지도에서 그림을 그리기 위해 문제가 있습니다. 위치 편집 포인트를 편집 할 때 Google지도에서 내 포인트를 복제하고 이전 포인트와 새 포인트를 얻습니다.Google지도 : 올바른 위치를 생성 한 후 내지도 업데이트

let pointCord = [];  
function createRoute(e) { 
const lat = e.latLng.lat(); 
const lng = e.latLng.lng(); 

pointCord.push(new google.maps.LatLng(lat, lng)); 

const flightPathOptions = { 
    path: pointCord, 
    editable: true, 
    draggable: true, 
    strokeColor: '#000', 
    strokeOpacity: 1.0, 
    strokeWeight: 5, 
    map 
}; 

flightPath = new google.maps.Polyline(flightPathOptions); 
const getPath = flightPath.getPath(); 

map.addListener('click', createRoute); 

는이 코드

google.maps.event.addListener(getPath, 'set_at', function(){ 
    pointCord = getPath.getArray(); 
    createRoute(e); 
}); 

을 적용하려고하지만 나에게 도움이되지 않습니다. 이전 포인트를 삭제하고 내지도를 업데이트하는 방법은 무엇입니까?

답변

0

문제는 flightPath inner createRoute입니다. 당신의 비행 경로가 필요합니다.

const flightPathOptions = { 
     path: pointCord, 
     editable: true, 
     draggable: true, 
     strokeColor: '#000', 
     strokeOpacity: 1.0, 
     strokeWeight: 5, 
     map 
    }; 

    flightPath = new google.maps.Polyline(flightPathOptions); 
    const getPath = flightPath.getPath(); 

    function createRoute(e) { 
     getPath.push(e.latLng); 
    } 

    map.addListener('click', createRoute); 
관련 문제