我创建了一个Fusion地图,显示区域(http://58design.com/gmaps/test.html)的多边形“区域”。我想要做的是让用户输入一个地址,该地址将在我的地图上显示一个信息窗口的位置,该信息窗口具有与用户点击“区域”相同的信息。基本上我想要这样的东西(http://www.geocodezip.com/v3_collection-map2e_FT.html),但我想要我的地图/数据。
我找到了几个较旧的代码示例,但我似乎无法使用我创建的地图。这是我目前的代码:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport"></meta>
<title>SCV Sheriff Reporting Districts - Google Fusion Tables</title>
<style type="text/css">
html, body, #googft-mapCanvas {
height: 500px;
margin: 0;
padding: 0;
width: 500px;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
google.maps.visualRefresh = true;
var isMobile = (navigator.userAgent.toLowerCase().indexOf('android') > -1) ||
(navigator.userAgent.match(/(iPod|iPhone|iPad|BlackBerry|Windows Phone|iemobile)/));
if (isMobile) {
var viewport = document.querySelector("meta[name=viewport]");
viewport.setAttribute('content', 'initial-scale=1.0, user-scalable=no');
}
var mapDiv = document.getElementById('googft-mapCanvas');
mapDiv.style.width = isMobile ? '100%' : '500px';
mapDiv.style.height = isMobile ? '100%' : '500px';
var map = new google.maps.Map(mapDiv, {
center: new google.maps.LatLng(34.41269001087864, -118.55340000000001),
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(document.getElementById('googft-legend-open'));
map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(document.getElementById('googft-legend'));
layer = new google.maps.FusionTablesLayer({
map: map,
heatmap: { enabled: false },
query: {
select: "col2",
from: "1uSGM1yPMJBlu74Znm4fPqdCsJjteB_kQ_nGz3tk",
where: ""
},
options: {
styleId: 2,
templateId: 2
}
});
if (isMobile) {
var legend = document.getElementById('googft-legend');
var legendOpenButton = document.getElementById('googft-legend-open');
var legendCloseButton = document.getElementById('googft-legend-close');
legend.style.display = 'none';
legendOpenButton.style.display = 'block';
legendCloseButton.style.display = 'block';
legendOpenButton.onclick = function() {
legend.style.display = 'block';
legendOpenButton.style.display = 'none';
}
legendCloseButton.onclick = function() {
legend.style.display = 'none';
legendOpenButton.style.display = 'block';
}
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googft-mapCanvas"></div>
</body>
</html>
答案 0 :(得分:1)
将FusionTableID更改为您的表格
var FusionTableID = '1uSGM1yPMJBlu74Znm4fPqdCsJjteB_kQ_nGz3tk';
更改表的GViz查询以使用正确的列名
var queryText ="SELECT 'name', 'Zone Area' FROM "+FusionTableID+" WHERE ST_INTERSECTS(\'Zone Area\', CIRCLE(LATLNG(" + point.toUrlValue(6) + "),0.5));";
更改FusionTables图层以使用加密ID的新语法。
layer = new google.maps.FusionTablesLayer({query:{from:FusionTableID},suppressInfoWindows:true});