我在地图中使用了标记和方向服务.
我使用了bounds.extend(lat),map.fitBounds(bounds);来扩展地图以显示我的所有标记.这工作正常,直到我使用方向服务.一旦使用方向,地图自动缩放到从A到B的方向.现在只能在地图中看到指向A和B的两个标记.
但我希望地图显示所有标记与两个其他标记之间使用的方向.
我怎么能这样做?
Issue solved by using the following line
var directionsDisplay = new google.maps.DirectionsRenderer({
preserveViewport:true
});
Run Code Online (Sandbox Code Playgroud)
如果您不希望directionsRenderer缩放到其结果,请使用preserveViewport选项.
另一种选择是使用工会由为DirectionsService和您的标记计算边界返回的路线的边界.
| 归档时间: |
|
| 查看次数: |
786 次 |
| 最近记录: |