Javascript通过点击事件谷歌地图通过重叠的div? [英] Javascript passing click event to google maps through a overlapping div?

查看:99
本文介绍了Javascript通过点击事件谷歌地图通过重叠的div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我嵌入了谷歌地图。如果我把相同大小的div与高度和宽度相同的Google地图重叠...我可以使它的div的onclick事件将点击事件传递给地图,以便我仍然可以平移和放大地图,就好像重叠的div层不在那里一样?

解决方案

为什么你用div重叠它?



如果您正在尝试这样做,那么您也可以点击抓取用户,这样就不需要使用google maps api

  var map = new GMap2(document.getElementById(map)); 
map.setCenter(new GLatLng(37.4419,-122.1419),13);
GEvent.addListener(map,click,function(){
alert(您点击了地图。);
});

取自 http://code.google.com/intl/zh-CN/apis/maps/documentation/javascript/v2/ events.html


Say I have a google map embedded. If I put a div of the same size overlapping the google map with the same height and width... can I make it so that the onclick event of the div passes the click event to the map as well such that I can still pan and zoom around the map as if the overlapping div layer was not there?

解决方案

Why are you overlapping it with a div?

If you're trying to do that so you can grab users click too, there's no need for this, use google maps api

var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
GEvent.addListener(map, "click", function() {
  alert("You clicked the map.");
});

Example taken from: http://code.google.com/intl/en-US/apis/maps/documentation/javascript/v2/events.html

这篇关于Javascript通过点击事件谷歌地图通过重叠的div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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