现在,我正在创建一个地图,该地图将有一个 javascript 菜单,允许用户使用 Google fusion table 覆盖更改为不同的地图视图。如果您能帮助我解决一个阻碍我完成项目的问题,我将不胜感激。
这是我的谷歌地图 HTML 页面:
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<!DOCTYPE html>
<title>Met Sacramento Internship Map</title>
<!-- Style -->
<style>
body { font-family: Arial, sans-serif; }
#map_canvas { height: 500px; width:600px; }
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var tableid = 567682;
var layer = new google.maps.FusionTablesLayer(567682);
function initialize() {
var latlng = new google.maps.LatLng(37.5213829, -122.172534);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
layer.setMap(map);
}
//Change the query based on the user's selection
function changeMap(delivery) {
layer.setQuery("SELECT Address FROM " + tableid + " WHERE delivery LIKE '" + delivery + "'");
}
</script>
</script>
</head>
<body onload="initialize();">
Internship Status <select onchange="changeMap(this.value);">
<option value="%">--Select--</option>
<option value="ANIMALS">Animals</option>
<option value="BUSINESS">Business</option>
</select> <div id="map_canvas"></div>
</body>
</html>
添加此代码时出现我的问题:
//Change the query based on the user's selection
function changeMap(animals) {
layer.setQuery("SELECT Address FROM " + tableid + " WHERE Animals LIKE '" + Animals + "'");
任何帮助都将不胜感激,我对融合表、Google Maps API 和 Javascript 还很陌生。