Javascript 向Wordpress添加可搜索地图
我是fusion tables和google maps API的新手,希望答案是直截了当的!我使用融合表创建了数据点地图,并添加了搜索功能 然而,地图只是在消失前短暂出现,被一条“对不起,出了什么事”的信息所取代。我已经检查了代码,无法找出错误所在 请有人看一看,并建议什么需要改变 以下是该页面的链接: 我的代码是:Javascript 向Wordpress添加可搜索地图,javascript,google-maps,google-fusion-tables,Javascript,Google Maps,Google Fusion Tables,我是fusion tables和google maps API的新手,希望答案是直截了当的!我使用融合表创建了数据点地图,并添加了搜索功能 然而,地图只是在消失前短暂出现,被一条“对不起,出了什么事”的信息所取代。我已经检查了代码,无法找出错误所在 请有人看一看,并建议什么需要改变 以下是该页面的链接: 我的代码是: <!DOCTYPE html> <html> <head> <style> #map-canvas { widt
<!DOCTYPE html>
<html>
<head>
<style>
#map-canvas { width:800px; height:800px; }
.layer-wizard-search-label { font-family: sans-serif };
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
var map;
var layer_0;
function initialize() {
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(52.90081096506728, -0.8806991343750425),
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
layer_0 = new google.maps.FusionTablesLayer({
query: {
select: "col2",
from: "1LP8RhZ3QlYREIJB3e1xogaHWVmL8qxAUjKW1R6XE"
},
map: map,
styleId: 2,
templateId: 2
});
}
function changeMap_0() {
var whereClause;
var searchString = document.getElementById('search-string_0').value.replace(/'/g, "\\'");
if (searchString != '--Select--') {
whereClause = "'School Name' CONTAINS IGNORING CASE '" + searchString + "'";
}
layer_0.setOptions({
query: {
select: "col2",
from: "1LP8RhZ3QlYREIJB3e1xogaHWVmL8qxAUjKW1R6XE",
where: whereClause
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
<div style="margin-top: 10px;">
<label class="layer-wizard-search-label">
School Name
<input type="text" id="search-string_0">
<input type="button" onclick="changeMap_0()" value="Search">
</label>
</div>
</body>
</html>
带AppId和AppSecret密钥的map init在哪里?您必须在页面的init上使用此函数调用Google应用程序。请参阅此Google Map Api JS
谢谢-你说得对。我没有将initMap代码添加到主体中。我已经用我的API密钥添加了这个,现在它似乎正在工作。很高兴听到这个消息,请不要犹豫,关闭您的答案;