markerCluster 中不允许使用 anchorText
anchorText not allowed in markerCluster
所以我为我的集群使用了自定义图标,这会导致文本偏离中心。没问题吧?只使用锚文本?嗯,有问题。
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);
所以问题是,如果我使用 'AnchorText' 的新命名,我会收到以下错误(但是,它会正确地将我的文本居中)
Argument of type '{ maxZoom: number; styles: { url: string; width: number; height: number; textSize: number; textColor: string; anchorText: number[]; }[]; }' is not assignable to parameter of type 'MarkerClustererOptions'.
Types of property 'styles' are incompatible.
Type '{ url: string; width: number; height: number; textSize: number; textColor: string; anchorText: number[]; }[]' is not assignable to type
此错误不会停止 angular 正确显示(但我无法检查错误,因为它不会通过构建测试)
现在,如果我将其更改为 'anchor'(显然是对象的旧名称),它会消除错误,但实际上不会使文本居中。
我使用的是最新版本:"@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);
所以我为我的集群使用了自定义图标,这会导致文本偏离中心。没问题吧?只使用锚文本?嗯,有问题。
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);
所以问题是,如果我使用 'AnchorText' 的新命名,我会收到以下错误(但是,它会正确地将我的文本居中)
Argument of type '{ maxZoom: number; styles: { url: string; width: number; height: number; textSize: number; textColor: string; anchorText: number[]; }[]; }' is not assignable to parameter of type 'MarkerClustererOptions'.
Types of property 'styles' are incompatible.
Type '{ url: string; width: number; height: number; textSize: number; textColor: string; anchorText: number[]; }[]' is not assignable to type
此错误不会停止 angular 正确显示(但我无法检查错误,因为它不会通过构建测试)
现在,如果我将其更改为 'anchor'(显然是对象的旧名称),它会消除错误,但实际上不会使文本居中。
我使用的是最新版本:"@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);