【问题标题】:Zooming and directions services缩放和方向服务
【发布时间】:2012-04-28 05:46:41
【问题描述】:

我希望强制 Google 方向服务放大到最终目的地,而不是显示整个路线。这可能吗?如果是这样,你会怎么做?一旦设置了开始和结束位置并调用了计算路线功能,我还想删除我设置的标记,这可能吗?我认为任何代码都不会帮助它在 v3 中完成。我一直在搜索,没有发现与缩放问题有关的任何内容。谁能帮忙...

【问题讨论】:

    标签: android iphone google-maps-api-3


    【解决方案1】:

    在初始化方向渲染器时首先传递这些选项:

    {suppressMarkers:true,preserveViewport:true}
    

    ...所以你不会得到标记,并且地图在渲染时将不适合路线的边界。

    然后,在渲染路线(setDirections())之后,调用这个:

          directionsDisplay.setDirections(response);
            //set the center of the map to the end of the route
          map.setCenter(response.routes[0].legs[response.routes[0].legs.length-1].end_location);
            //set the zoom to the desired value
    

    (其中directionsDisplay是directionsRenderer-instance)

    【讨论】:

      【解决方案2】:

      这确实有帮助,现在看看它,我想也许应该添加我的代码。我先在这里试试。我希望“A”和“B”标记保留我已经为其他标记构建了数组额外的转弯指示。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-26
        • 1970-01-01
        • 1970-01-01
        • 2014-08-19
        • 2020-03-14
        • 1970-01-01
        • 2017-08-01
        • 1970-01-01
        相关资源
        最近更新 更多