谷歌地图 API 不会在不同的大陆上绘制 [英] Google map API does not plot on different continents

查看:30
本文介绍了谷歌地图 API 不会在不同的大陆上绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌地图 API 在谷歌地图上绘制了一个航点

I have used the google map API to plot a way point on google map

我参考了以下页面:

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

在路线部分使用航点"并对其进行了一些修改,以便在地图上仅绘制 3 个点.以下是我的javascript代码.

'Using Waypoints in Routes section' and modified it a bit so as to plot only 3 points on the map. The following is my javascript code.

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 个地点在同一个国家/地区内,则效果很好,即它们有路线图.

which works perfectly fine if the 3 locations are within same country, ie they have a road map.

我的问题是当位置在不同的大陆(例如印度和澳大利亚)时如何绘制地图?

My question is how to plot the map when the location are in different continents eg India and Australia?

任何人都可以帮忙.

提前致谢.

推荐答案

问题不在于不同的大陆,而在于路由引擎的数据库是否有关于起点和终点之间所有国家/地区的信息,包括汽车渡轮.您可以看到,在 maps.google.com 中也发生了同样的情况.这是一条从欧洲到印度的洲际航线您尝试将 B 标记移动到美国或加拿大,它没有找到路线,因为它不知道横渡大西洋的渡轮.您可以在此电子表格中查看覆盖的国家/地区.

The problem is not about different continents, but whether the routing engine's database has information about all the countries between your start and endpoints, including car ferries. You can see that the same occurs in maps.google.com . Here's an intercontinental route from Europe to India, but if you try to move the B marker to the US or Canada, it doesn't get a route because it doesn't know a ferry across the Atlantic. You can see what countries have coverage in this spreadsheet.

这篇关于谷歌地图 API 不会在不同的大陆上绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆