Google maps api 3 markerCluster中不允许使用anchorText
所以我在集群中使用了一个自定义图标,这会导致文本偏离中心。没问题,对吧?就用anchorText吧?嗯,有些问题Google maps api 3 markerCluster中不允许使用anchorText,google-maps-api-3,Google Maps Api 3,所以我在集群中使用了一个自定义图标,这会导致文本偏离中心。没问题,对吧?就用anchorText吧?嗯,有些问题 let anchor: Array<number> = [9,3]; let styles = [{ url: "../../assets/img/mapIcons/clusterDot.svg", width: 50, height:50, textSize:25,
let anchor: Array<number> = [9,3];
let styles = [{
url: "../../assets/img/mapIcons/clusterDot.svg",
width: 50,
height:50,
textSize:25,
textColor:"white",
anchorText: anchor,
}];
this.markerClusterer = new MarkerClusterer(this.map, this.markers, mcOptions);
此错误不会停止正确显示(但我无法检入错误,因为它不会通过构建测试)
现在,如果我将其更改为“锚定”(显然是对象的旧名称),它将删除错误,但实际上不会使文本居中
我使用的是最新版本:“@googlemaps/markerclustererplus”:“^1.0.3”
我应该怎么做
谢谢因此,尽管没有人在所有在线示例中显示使用此功能,但我确实在bitBucket中找到了此功能。WithDefaultStyles允许您正确设置锚文本
let styles = [
MarkerClusterer.withDefaultStyle({
url: "../../assets/img/mapIcons/clusterDot.svg",
width: 56,
height:56,
textSize:25,
textColor:"white",
anchorText: [-4, 0]
})]
let mcOptions = {
maxZoom:21,
styles:styles
};
this.markerClusterer = new MarkerClusterer(this.map, this.markers, mcOptions);
Hi Limey,您应该在这里定义样式类型,以避免您所面临的anchorText错误。像let styles:ClusterIconStyle[]=[MarkerClusterer.withDefaultStyle({url:../../assets/img/mapIcons/clusterDot.svg],宽度:56,高度:56,文本大小:25,文本颜色:“白色”,anchorText:[-4,0]})],那么它将允许您无误地使用anchorText。即使anchorText工作正常,我也面临这个错误,但angular在定义了它工作的类型之后,不允许我创建构建。
let styles = [
MarkerClusterer.withDefaultStyle({
url: "../../assets/img/mapIcons/clusterDot.svg",
width: 56,
height:56,
textSize:25,
textColor:"white",
anchorText: [-4, 0]
})]
let mcOptions = {
maxZoom:21,
styles:styles
};
this.markerClusterer = new MarkerClusterer(this.map, this.markers, mcOptions);