gpt4 book ai didi

javascript - 将样式应用于融合表上的图标时,得到意外的标识符

转载 作者:行者123 更新时间:2023-11-28 17:15:53 24 4
gpt4 key购买 nike

有一张我使用 Google Maps API 和 Fusion Tables 制作的 map 。我正在尝试更改 map 上标记的外观。

当我添加“样式”时,https://developers.google.com/maps/documentation/javascript/fusiontableslayer我的 map 不会加载到页面上,并且我在控制台中收到一条错误消息:“意外的标识符 - 样式”

谁能帮我弄清楚我做错了什么?

这是我的代码:

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);

最佳答案

我相信你在 styles 之前少了一个逗号

layer = new google.maps.FusionTablesLayer({
query: {
select: '\'Geocodable address\'',
from: '1x265dMvUClEGEVHD_3VRBvSRXk-mbs4jcO2xy29K',
}, //need a comma here
styles: [{...

关于javascript - 将样式应用于融合表上的图标时,得到意外的标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28573054/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com