사용자의 현재 위치에서 선택한 타겟까지의 경로를 만들려고합니다. 문제는 내가 사용자가 다음과 같습니다 내 경로 기능에/경도 위도 얻는 방법을 모르는입니다 :MapQuest Directions API를 사용하여 사용자로부터 경로 생성하기
getRoute = function(){
dir = MQ.routing.directions()
.on('success', function(data) {
//does some stuff with the routes data/directions. not important here
});
dir.route({
locations: [
{ latLng: { lat: USER LAT HERE, lng: USER LNG HERE } },
{ latLng: { lat: (poiCoordinates.lat), lng: (poiCoordinates.lng) } }
],
options: {
//not important as well
}
});
mqroute = MQ.routing.routeLayer({
directions: dir,
}).addTo(map);
};
기능은 위의 사용자가 예를 들어 A에 대한 관심의 포인트를 선택 할 때 호출되는 레스토랑을 선택하고 '경로 찾기'버튼을 클릭합니다. Leaflet locate 함수에 액세스 할 수 있지만이를 결합하여 위의 getRoute 함수로 사용자 geolocation을 얻는 방법을 알지 못합니다. 그것을 할 방법에 대한 제안? 건배!