Javascript TypeError:google.maps.MarkerLabel不是构造函数
我想用Google Maps V3自定义标记标签的颜色,在文档中搜索我发现有一个名为Google.Maps.MarkerLabel的类 在网上搜索,我找到了一些用法的解释,下面是我尝试做的:Javascript TypeError:google.maps.MarkerLabel不是构造函数,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我想用Google Maps V3自定义标记标签的颜色,在文档中搜索我发现有一个名为Google.Maps.MarkerLabel的类 在网上搜索,我找到了一些用法的解释,下面是我尝试做的: var marker = new google.maps.Marker ({ position: new google.maps.LatLng(data.lat, data.lon), map: map, id: dat
var marker = new google.maps.Marker ({
position: new google.maps.LatLng(data.lat, data.lon),
map: map,
id: data.id,
type: data.type,
type_description: data.type_description,
name: data.name,
via: data.via,
civico: data.civico,
comune: data.comune,
cap: data.cap,
giorno: data.giorno,
orario: data.orario,
description: data.description,
note: data.note,
label: new google.maps.MarkerLabel({
text: data.id,
color: "white"
}),
icon: '<cms:link>../resources/images/' + data.markerIcon + '</cms:link>'
});
var marker=new google.maps.marker({
位置:新的google.maps.LatLng(data.lat,data.lon),
地图:地图,
id:data.id,
type:data.type,
类型描述:data.type描述,
name:data.name,
via:data.via,
civico:data.civico,
comune:data.comune,
cap:data.cap,
giorno:data.giorno,
orario:data.orario,
description:data.description,
注:data.note,
标签:新google.maps.MarkerLabel({
text:data.id,
颜色:“白色”
}),
图标:'../resources/images/'+data.markerIcon+''
});
消息告诉我MarkerLabel不是一个构造函数。好的,但是我应该在哪里调用它,以使按对象id(当然是一个数字)变为白色
谢谢 a没有构造函数,它是一个匿名对象
像这样使用它:
var marker = new google.maps.Marker ({
position: map.getCenter(),
map: map,
label: {
text: "A", // data.id,
color: "white"
}
});
代码片段:
函数初始化(){
var map=new google.maps.map(
document.getElementById(“地图画布”){
中心:新google.maps.LatLng(37.4419,-122.1419),
缩放:13,
mapTypeId:google.maps.mapTypeId.ROADMAP
});
var marker=new google.maps.marker({
位置:map.getCenter(),//新建google.maps.LatLng(data.lat,data.lon),
地图:地图,
标签:{
案文:“A”,
颜色:“白色”
}
});
}
google.maps.event.addDomListener(窗口“加载”,初始化)代码>
html,
身体,
#地图画布{
身高:100%;
宽度:100%;
边际:0px;
填充:0px
}