【发布时间】:2015-02-17 23:15:01
【问题描述】:
有一张我使用 Google Maps API 和 Fusion Tables 制作的地图。我正在尝试更改地图上标记的外观。
当我添加“样式”时,https://developers.google.com/maps/documentation/javascript/fusiontableslayer 我的地图将不会加载到页面上,并且我的控制台读取错误:“意外标识符 - 样式”
谁能帮我弄清楚我做错了什么?
这是我的代码:
var map, layer;
var geocoder;
function initialize(location) {
console.log(location);
geocoder = new google.maps.Geocoder();
var userlocation = new google.maps.LatLng(location.coords.latitude, location.coords.longitude);
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: userlocation,
zoom: 8
});
layer = new google.maps.FusionTablesLayer({
query: {
select: '\'Geocodable address\'',
from: '1x265dMvUClEGEVHD_3VRBvSRXk-mbs4jcO2xy29K',
}
styles: [
{markerOptions:{ iconName:"star"}}
]
});
layer.setMap(map);
}
function codeAddress() {
var address = document.getElementById('address').value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
navigator.geolocation.getCurrentPosition(initialize);
【问题讨论】:
标签: javascript css google-maps google-maps-api-3