谷歌地图放大后的方向 [英] google map zoom after directions

查看:152
本文介绍了谷歌地图放大后的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



虽然,我已将地图的缩放比例设置为15,但放大更改在方向请求响应之后,可能会将方向放入地图中。



是否有人不知道如何让缩放常数保持在15.并且专注于第一个点?



预先感谢。

解决方案

DirectionsRenderer

  preserveViewport:true 

将阻止DirectionsRenderer更改zoom。



要使地图在第一个点上居中,请使用map.setCenter函数。您需要解析路线服务的响应,并为第一个点创建一个google.maps.LatLng对象。



这个例子展示了解析响应的一种方式:

http://www.geocodezip.com/v3_directions_custom_iconsC.html



<你>不需要任何东西,仅仅是你想要的点的位置)

i am using google maps in order to give some directions from one point to another.

Although, i have set the zoom of the map to 15 the zoom changes after the response of the direction request in order probably to fit the directions into the map.

Does anyone nows how to keep the zoom constant at 15. and focus at the first point?

Thanks in advance.

解决方案

See the documentation for the DirectionsRenderer

preserveViewport: true

will prevent the DirectionsRenderer from changing the zoom.

To center the map on the first point use the map.setCenter function. You will need to parse the response from the directions service and create a google.maps.LatLng object for the first point.

This example shows one way to parse the response:

http://www.geocodezip.com/v3_directions_custom_iconsC.html

(you don't need everything, just the location of the point you want to center on)

这篇关于谷歌地图放大后的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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