Javascript 如何检测谷歌地图上的放大/缩小按钮
在谷歌地图Javascript 如何检测谷歌地图上的放大/缩小按钮,javascript,jquery,google-maps,Javascript,Jquery,Google Maps,在谷歌地图zoom\u changed中,可以通过双击,鼠标同时单击或放大/缩小按钮来调用事件。我的问题是,如何通过单击放大/缩小按钮来检测缩放更改 我试图从函数中捕获事件,但未定义它 google.maps.event.addListener(MAP_PROPERTIES.map, 'zoom_changed', function(e) { self.closeInfoWindow(); if(MAP_PROPERTIES.user_interaction == true &
zoom\u changed
中,可以通过双击,鼠标同时单击或放大/缩小按钮来调用事件。我的问题是,如何通过单击放大/缩小按钮来检测缩放更改
我试图从函数中捕获事件
,但未定义它
google.maps.event.addListener(MAP_PROPERTIES.map, 'zoom_changed', function(e)
{
self.closeInfoWindow();
if(MAP_PROPERTIES.user_interaction == true && MAP_PROPERTIES.currentZoomLevel != MAP_PROPERTIES.map.getZoom() )
{
VRS.TRACE(e); // e is undefined here
/*My functionalities here*/
}
});
如果您有任何建议,我们将不胜感激。我刚刚发现了这把小提琴,其中添加了自定义缩放控件。因此,您可以轻松地添加事件侦听器。 或者尝试将事件侦听器添加到此
$('[title=“Zoom out”]')
var zoomInButton = document.createElement('div');
zoomInButton.style.width = '32px';
zoomInButton.style.height = '32px';
/* Change this to be the .png image you want to use */
zoomInButton.style.backgroundImage = 'url("http://placehold.it/32/00ff00")';
controlWrapper.appendChild(zoomInButton);
// Setup the click event listener - zoomIn
google.maps.event.addDomListener(zoomInButton, 'click', function() {
map.setZoom(map.getZoom() + 1);
});