2
下面的代碼查詢基於一個圓形區域地圖谷歌的融合表。谷歌地圖融合:圈阻擋層的點擊事件,JavaScript
圓形地圖區域的中心由其中用戶點擊和半徑由選擇從從下拉菜單中確定確定。我有一個監聽器中,這樣當用戶點擊映射點的信息框出現顯示從相應的融合錶行的信息。
這一切都工作正常,直到我添加一個圓到我的地圖(向用戶說明他們選擇的區域),看起來圓的存在阻止了圖層的點擊事件偵聽器。我試過改變z-index無濟於事。任何人都可以請建議解決這個問題的方法?
function initialize() {
tableid = xxxxxxx;
// Initialize the Google Map
var map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(37.3, -122.3),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'Address',
from: tableid,
where: 'ST_INTERSECTS(Address, CIRCLE(LATLNG(37.3, -122.3), 5000))'
}
});
layer.setMap(map);
layer.index = 1;
map.index =2;
var meters = 5000;
var center = map.getCenter();
// Update the radius when the user makes a selection.
google.maps.event.addDomListener(document.getElementById('radius'), 'change', function() {
meters = parseInt(this.value, 10);
circle.setRadius(meters);
searchStr = 'ST_INTERSECTS(Address, ' +'CIRCLE(LATLNG'+center+', ' + meters + '))'
searchStr += " AND " + "filter_1 IN ("+filterSelection+")";
layer.setOptions({
query: {
select: 'Address',
from: tableid,
where: searchStr
}
});
}); //Update the filter when the user makes a selection.
google.maps.event.addDomListener(document.getElementById('filter'),'change', function() {
filterSelection = this.value;
searchStr = 'ST_INTERSECTS(Address, ' + 'CIRCLE(LATLNG'+center+', ' + meters + '))'
searchStr += " AND " + "filter_1 IN ("+filterSelection+")";
layer.setOptions({
query: {
select: 'Address',
from: tableid,
where: searchStr
}
});
});
//Info Box Populate click handler
google.maps.event.addListener(layer, 'click', function(e) {
alert("Info Click");
e.infoWindowHtml = e.row['Title'].value + "<br>";
});
//Click Handler
google.maps.event.addListener(map, 'click', function(e) {
circle.setCenter(e.latLng);
center = e.latLng;
searchStr = 'ST_INTERSECTS(Address, ' + 'CIRCLE(LATLNG'+e.latLng+', ' + meters + '))'
searchStr += " AND " + "filter_1 IN ("+filterSelection+")";
layer.setOptions({
query: {
select: 'Address',
from: tableid,
where: searchStr
}
});
});
// Create a map circle object to visually show the radius.
var circle = new google.maps.Circle({
center: new google.maps.LatLng(37.3, -122.3),
radius: 5000,
map: map,
fillOpacity: 0.1,
strokeOpacity: 0.5,
strokeWeight: 1
});
circle.index = 0;
circle.setmap(map);
}
它的工作原理!非常感謝,不能告訴你這是什麼休息! –
我有同樣的問題,這是天賜之物! – revolver
謝謝!我也是! :) – NSTJ