希望这是有道理的。我将两张表合并在一起,一张包含有关电话交换机及其在英国的具体位置的信息,另一张包含英国的地区信息。我想要做的是,当我滚动或单击一个区域时,我希望能够在我的网页面板上列出属于该区域的所有交易所。在我单击一个区域时,会显示表中的最后一个交易所。我猜这可能是我需要在 addListeners2() 函数中做的简单事情。任何指向正确方向的指针将不胜感激。
var map, layer;
function initialize()
{
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(54.54658,-4.87793),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
loadPoint();
}
function loadPoint()
{
if (layer != null)
{
layer.setMap(null);
google.maps.event.clearInstanceListeners(layer);
}
var tableid = '3569550';
layer = new google.maps.FusionTablesLayer
({
query:
{
select: 'LATITUDE',
from: tableid
//where: 'latitude is not null'
},
map: map
})
layer.enableMapTips({
select: "'REGION','EXCHANGE','MPF','WLR','SMPF','BB_CONNECT'", // list of columns to query, typially need only one column.
from: tableid, // fusion table name
geometryColumn: 'LATITUDE', // geometry column name
suppressMapTips: true, // optional, whether to show map tips. default false
delay: 100, // milliseconds mouse pause before send a server query. default 300.
tolerance: 8 // tolerance in pixel around mouse. default is 6.
});
addListeners1();
}
function loadRegion()
{
if (layer != null)
{
layer.setMap(null);
google.maps.event.clearInstanceListeners(layer);
}
var tableid = '3569550';
layer = new google.maps.FusionTablesLayer
({
query:
{
select: 'geometry',
from: tableid
},
map: map
})
layer.enableMapTips({
select: "'REGION','EXCHANGE','MPF','WLR','SMPF','BB_CONNECT'",
from: tableid, // fusion table name
geometryColumn: 'geometry', // geometry column name
suppressMapTips: true, // optional, whether to show map tips. default false
delay: 100, // milliseconds mouse pause before send a server query. default 300.
tolerance: 8 // tolerance in pixel around mouse. default is 6.
});
addListeners2();
}
function addListeners1()
{
google.maps.event.addListener(layer, 'mouseover', function(fEvent)
{
var row = fEvent.row;
myHtml = '<TABLE width = "600" cellspacing="0" cellpadding="0"><TR>';
myHtml += '<TD><b>REGION</b></TD>';
myHtml += '<TD><b>EXCHANGE</b></TD>';
myHtml += '<TD><b>MPF</b></TD>';
myHtml += '<TD><b>WLR</b></TD>';
myHtml += '<TD><b>SMPF</b></TD>';
myHtml += '<TD><b>BB_CONNECT</b></TD></TR><TR>';
for (var x in row)
{
if (row.hasOwnProperty(x))
{
myHtml += '<td>' + row[x].value +'</td>';
}
}
myHtml += '</TR></TABLE>';
document.getElementById('info').innerHTML = myHtml;
});
}
function addListeners2()
{
google.maps.event.addListener(layer, 'mouseover', function(fEvent)
{
var row = fEvent.row;
myHtml = '<TABLE width = "600" cellspacing="0" cellpadding="0"><TR>';
myHtml += '<TD><b>REGION</b></TD>';
myHtml += '<TD><b>EXCHANGE</b></TD>';
myHtml += '<TD><b>MPF</b></TD>';
myHtml += '<TD><b>WLR</b></TD>';
myHtml += '<TD><b>SMPF</b></TD>';
myHtml += '<TD><b>BB_CONNECT</b></TD></TR><TR>';
for (var x in row)
{
if (row.hasOwnProperty(x))
{
myHtml += '<td>' + row[x].value +'</td>';
}
}
myHtml += '</TR></TABLE>';
document.getElementById('info').innerHTML = myHtml;
});
}
}