小编use*_*930的帖子

Google地图中的拟合边界渲染方向

我正在尝试为48个航点提供方向,但谷歌只允许每个请求渲染8个航点.所以我做了多个请求(在我的情况下是6).但是,API以某种方式为最后一个请求执行了fitBounds().

如何使用fitBounds()和/或setZoom()在一个地图中显示所有48个航路点

我的代码如下: -

function DisplayDirection(directionList){

    var interval = 8; // upper bound for usage limits in google directions API is 8
    var startIndex =0;
    var maxmimumIndex = directionList.length-1; // Total number of waypoints in this route
    var partialEndIndex = interval-1; // end waypoint at start
    var iteration = 0; // loop controler
    directionsService = new google.maps.DirectionsService();
    var resultSet = new Array();
    var directionsDisplayList = new Array();
    var resultsCached = 0;
    var bounds = new google.maps.LatLngBounds();

    do { //do...while to …
Run Code Online (Sandbox Code Playgroud)

javascript jquery google-maps google-maps-api-3 fitbounds

3
推荐指数
2
解决办法
4947
查看次数