2
我已經使用了谷歌地圖API繪製在谷歌地圖上航點繪製谷歌地圖API不會在不同的大洲
我提到了以下頁面:
https://developers.google.com/maps/documentation/javascript/directions
「使用航點中的航點「部分,並對其進行了修改,以便在地圖上只繪製3點。 以下是我的javascript代碼。
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個位置在同一個國家內,即它們具有路線圖,那麼它可以很好地工作。
我的問題是如何繪製地圖時,位置在不同的大洲,如印度和澳大利亞?
任何人都可以請幫忙。
在此先感謝。
爲什麼你會期望能夠從印度到澳大利亞的駕車路線? – geocodezip 2012-08-03 09:43:31
你還能怎麼做 – 2012-08-03 10:54:54
如果你的目標是在兩個大洲之間畫一條折線,方向服務(返回「方向」)是錯誤的。使用google.maps.Polyline。 – geocodezip 2012-08-03 11:08:14