Google路线规划师缩放中心 [英] Google route planner zoom center

查看:122
本文介绍了Google路线规划师缩放中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用了Google路线规划工具,并在旁边有指示面板。当你点击某个陪审员的某个部分时,它会在地图上放大,但不会居中。是否有可能把它集中在地图的midle中?

解决方案

没有实现的选项来控制任何东西,当你点击面板。

但是你可以做什么:当你点击面板时,infoWindow打开。
您可以创建自己的infoWindow对象,并将其作为infoWindow选项传递给directionsRenderer。

然后你就可以控制infoWindow。观察infoWindow的domready事件(它将在infoWindow打开之前触发),并将地图的中心设置为infoWindow的getPosition()方法返回的值。

  //显示路线
if(!Demo.iw){
Demo.iw = new google.maps.InfoWindow();
google.maps.event
.addListener(Demo.iw,'domready',
function(){Demo.map.setCenter(this.getPosition());});
}
Demo.dirRenderer.setOptions({
map:Demo.map,
panel:Demo.dirContainer,
infoWindow:Demo.iw,
方向:dirResult
});


Im using Google route planner on my website with directions panel on the side. When you click on certain part of a jurney it gets zoomed in on the map but its not centered. Is it possible to center it in the midle of the map?

解决方案

There is no implemented option to control anything when you click on the panel.

But what you can do: When you click on the panel, the infoWindow opens. You may create your own infoWindow-object and pass it as infoWindow-option to the directionsRenderer.

Then you'll be able to control the infoWindow. Observe the domready-event of the infoWindow(it will fire before the infoWindow opens), and set the center of the map to the value returned by the getPosition()-method of the infoWindow.

// Show directions
if(!Demo.iw){
  Demo.iw=new google.maps.InfoWindow();
  google.maps.event
    .addListener(Demo.iw,'domready',
                 function(){Demo.map.setCenter(this.getPosition());});
}
Demo.dirRenderer.setOptions({
                    map         : Demo.map,
                    panel       : Demo.dirContainer,
                    infoWindow  : Demo.iw,
                    directions  : dirResult
});

这篇关于Google路线规划师缩放中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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