MarkerWIthLabel 地图库:this.setValue 不是函数
MarkerWIthLabel maps library: this.setValue is not a function
我有一个 JavaScript 应用程序,我正在尝试使用 MarkerWithLabel
库向地图上的标记添加 CSS 样式。
在我的 CSS 文件中,我添加了标签 class:
.labels {
color: red;
background-color: white;
font-size: 10px;
font-weight: bold;
text-align: center;
width: 60px;
border: 2px solid black;
white-space: nowrap;
}
并且,在 JavaScript 代码中,我使用 MarkerWithLabel
class 而不是默认的 google.maps.Marker
var marker = new MarkerWithLabel({
position: new google.maps.LatLng(lat, lon),
draggable: false,
raiseOnDrag: false,
map: map,
labelContent: "my label text",
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels",
labelStyle: {opacity: 1.0}
});
我一使用新的 class 就收到这个错误:
TypeError: this.setValues is not a function
at MarkerWithLabel.gf (js?key=MYGOOGLEKEY&callback=loadMapsApiEnd&libraries=places&_=1544699657828
我不知道这个文件是什么:MarkerWithLabel.gf
我已经包含了这个 .js 文件:
https://github.com/googlemaps/v3-utility-library/blob/master/markerwithlabel/src/markerwithlabel.js
我刚发现问题,我不得不在 Google 地图 API 库
之后包含 MarkerWithLabel.js
我有一个 JavaScript 应用程序,我正在尝试使用 MarkerWithLabel
库向地图上的标记添加 CSS 样式。
在我的 CSS 文件中,我添加了标签 class:
.labels {
color: red;
background-color: white;
font-size: 10px;
font-weight: bold;
text-align: center;
width: 60px;
border: 2px solid black;
white-space: nowrap;
}
并且,在 JavaScript 代码中,我使用 MarkerWithLabel
class 而不是默认的 google.maps.Marker
var marker = new MarkerWithLabel({
position: new google.maps.LatLng(lat, lon),
draggable: false,
raiseOnDrag: false,
map: map,
labelContent: "my label text",
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels",
labelStyle: {opacity: 1.0}
});
我一使用新的 class 就收到这个错误:
TypeError: this.setValues is not a function at MarkerWithLabel.gf (js?key=MYGOOGLEKEY&callback=loadMapsApiEnd&libraries=places&_=1544699657828
我不知道这个文件是什么:MarkerWithLabel.gf
我已经包含了这个 .js 文件: https://github.com/googlemaps/v3-utility-library/blob/master/markerwithlabel/src/markerwithlabel.js
我刚发现问题,我不得不在 Google 地图 API 库
之后包含 MarkerWithLabel.js