来自融合 table 的行的点未显示在地图小工具中
Points for rows from fusion table not shown in map gadget
我有一张 Google Sites page 和一张 Google 地图,显示以色列的速度陷阱位置。
它显示来自 Google Fusion Tables table 的位置,通过将 'type' 列的值划分到桶中来显示地图上的位置。
请参阅下面的地图小工具 XML。
最近,我添加了几个新类型的新行 (7)。我发现这些新位置的点没有显示在我的 Google 站点页面上的地图小工具中。但是,在融合 table 页面中,我可以很好地看到这些位置。
知道为什么会发生这种情况吗?
谢谢,
亚龙
地图小工具XML:
(为清楚起见,删除了未使用的功能)
<Module>
<ModulePrefs
description="Israel Speed Traps"
width="500"
height="600">
</ModulePrefs>
<Content type="html"><![CDATA[
<!DOCTYPE html>
<html>
<head>
<style>
#map_canvas { width: 100%; height: 100%; }
</style>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false&language=iw"></script>
<script type="text/javascript">
var map;
var layer;
var tableid = 2943387;
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(32.407792,35.502319),
zoom: 8,
mapTypeId: google.maps.MapTypeId.HYBRID
});
layer = new google.maps.FusionTablesLayer(tableid);
layer.setQuery("SELECT 'Location' FROM " + tableid);
layer.setMap(map);
}
</script>
</head>
<body onload="initialize();">
<div id="map_canvas"></div>
</body>
</html>
]]></Content>
</Module>
您的代码使用了错误的 tableId
。
你说的table的ID是1uMTPGcFuJsNxKcCLkSxAOIMJCrlzNIV46MUTlD4
,
但是您的代码指向 ID 为 1OZ8ty7BP3di6WVEwtM-CTJhoQaNlIpZowsSHkHPR
的另一个 table,它不包含带有 type:7
的行
此外,当您想在小工具中应用相同的外观时,您还必须定义 templateId
(对于信息窗口)和 styleId
(对于功能样式)
固定脚本:
<script type="text/javascript">
var map,
layer,
tableid = '1uMTPGcFuJsNxKcCLkSxAOIMJCrlzNIV46MUTlD4';
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(32.407792,35.502319),
zoom: 8,
mapTypeId: google.maps.MapTypeId.HYBRID
});
layer = new google.maps.FusionTablesLayer(tableid,{
options: {
styleId: 3,
templateId:3
}});
layer.setQuery("SELECT 'Location' FROM " + tableid);
layer.setMap(map);
}
</script>
我有一张 Google Sites page 和一张 Google 地图,显示以色列的速度陷阱位置。 它显示来自 Google Fusion Tables table 的位置,通过将 'type' 列的值划分到桶中来显示地图上的位置。 请参阅下面的地图小工具 XML。
最近,我添加了几个新类型的新行 (7)。我发现这些新位置的点没有显示在我的 Google 站点页面上的地图小工具中。但是,在融合 table 页面中,我可以很好地看到这些位置。
知道为什么会发生这种情况吗?
谢谢, 亚龙
地图小工具XML: (为清楚起见,删除了未使用的功能)
<Module>
<ModulePrefs
description="Israel Speed Traps"
width="500"
height="600">
</ModulePrefs>
<Content type="html"><![CDATA[
<!DOCTYPE html>
<html>
<head>
<style>
#map_canvas { width: 100%; height: 100%; }
</style>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false&language=iw"></script>
<script type="text/javascript">
var map;
var layer;
var tableid = 2943387;
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(32.407792,35.502319),
zoom: 8,
mapTypeId: google.maps.MapTypeId.HYBRID
});
layer = new google.maps.FusionTablesLayer(tableid);
layer.setQuery("SELECT 'Location' FROM " + tableid);
layer.setMap(map);
}
</script>
</head>
<body onload="initialize();">
<div id="map_canvas"></div>
</body>
</html>
]]></Content>
</Module>
您的代码使用了错误的 tableId
。
你说的table的ID是1uMTPGcFuJsNxKcCLkSxAOIMJCrlzNIV46MUTlD4
,
但是您的代码指向 ID 为 1OZ8ty7BP3di6WVEwtM-CTJhoQaNlIpZowsSHkHPR
的另一个 table,它不包含带有 type:7
此外,当您想在小工具中应用相同的外观时,您还必须定义 templateId
(对于信息窗口)和 styleId
(对于功能样式)
固定脚本:
<script type="text/javascript">
var map,
layer,
tableid = '1uMTPGcFuJsNxKcCLkSxAOIMJCrlzNIV46MUTlD4';
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(32.407792,35.502319),
zoom: 8,
mapTypeId: google.maps.MapTypeId.HYBRID
});
layer = new google.maps.FusionTablesLayer(tableid,{
options: {
styleId: 3,
templateId:3
}});
layer.setQuery("SELECT 'Location' FROM " + tableid);
layer.setMap(map);
}
</script>