Javascript通过点击事件谷歌地图通过重叠的div? [英] Javascript passing click event to google maps through a overlapping 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屋!