2012-08-03 5 views
2

다른 대륙에 플롯되지 않습니다구글 맵 API 내가 구글지도 방법의 포인트를 플롯하기 위해 구글 맵 API를 사용했다

나는 다음 페이지 참조 : 사용

https://developers.google.com/maps/documentation/javascript/directions

' Waypoints in Routes section '을 선택하고지도에서 3 점만 플롯하도록 조금 수정했습니다. 다음은 자바 스크립트 코드입니다.

var directionDisplay; 
var directionsService = new google.maps.DirectionsService(); 
var map; 

function initialize() { 
    directionsDisplay = new google.maps.DirectionsRenderer(); 
    var initialloc = new google.maps.LatLng(12.971599, 77.594563); 
    var mapOptions = { 
     zoom : 6, 
     mapTypeId : google.maps.MapTypeId.ROADMAP, 
     center : initialloc 
    } 
    map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); 
    directionsDisplay.setMap(map); 
    calcRoute(); 

} 

function calcRoute() { 
    var lat = new Array(); 
    var lon = new Array(); 

    var start = new google.maps.LatLng(12.971599,77.594563); 
    var mid = new google.maps.LatLng(12.971558,77.594552); 
    var end = new google.maps.LatLng(12.971558,77.594552); 

    var waypts = []; 
    waypts.push({ 
     location : mid, 
     stopover : true 
    }); 


    var request = { 
     origin : start, 
     destination : end, 
     waypoints : waypts, 
     optimizeWaypoints : true, 
     travelMode : google.maps.DirectionsTravelMode.DRIVING 
    }; 
    directionsService.route(
        request, 
        function(response, status) { 
         if (status == google.maps.DirectionsStatus.OK) { 
          directionsDisplay.setDirections(response); 
          var route = response.routes[0]; 

         } 
        }); 

} 

3 개국이 동일한 국가 내에있는 경우 완벽하게 작동합니다. 즉, 로드맵을 가지고 있습니다.

내 질문은 위치가 다른 대륙 (예 : 인도 및 호주)에있을 때지도를 플로팅하는 방법입니다.

아무도 도와 줄 수 있습니까? 사전에

감사합니다.

+0

인도에서 오스트레일리아로 운전 경로를 얻을 수 있기를 기대하는 이유는 무엇입니까? – geocodezip

+0

그 밖의 방법 –

+1

두 대륙간에 폴리 라인을 그리는 것이 목표 인 경우 길 찾기 서비스 ('길 찾기'를 반환 함)는 잘못된 것입니다. google.maps.Polyline을 사용하십시오. – geocodezip

답변

2

문제는 다른 대륙에 관한 것이 아니라 라우팅 엔진의 데이터베이스에 자동차 페리를 포함하여 시작과 종점 사이의 모든 국가에 대한 정보가 있는지 여부입니다. maps.google.com에서도 같은 결과가 발생합니다. Here's an intercontinental route에서 유럽으로 인도하지만 B 마커를 미국이나 캐나다로 옮기려한다면 대서양을 횡단하는 페리를 모르기 때문에 경로를 얻지 못합니다. 범위가 적용되는 국가는 this spreadsheet입니다.