google map zoom after directions

后端 未结 1 856
盖世英雄少女心
盖世英雄少女心 2021-01-12 12:06

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

相关标签:
1条回答
  • 2021-01-12 12:48

    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)

    0 讨论(0)
提交回复
热议问题