mirror of https://gitee.com/antv-l7/antv-l7
improvement: 聚合marker 支持设置普通marker样式
This commit is contained in:
parent
7348ca889d
commit
2a776809a6
|
@ -76,7 +76,7 @@ export default class MarkerLayer extends EventEmitter {
|
||||||
public addMarker(marker: IMarker) {
|
public addMarker(marker: IMarker) {
|
||||||
const cluster = this.markerLayerOption.cluster;
|
const cluster = this.markerLayerOption.cluster;
|
||||||
if (cluster) {
|
if (cluster) {
|
||||||
this.addPoint(marker);
|
this.addPoint(marker, this.markers.length);
|
||||||
}
|
}
|
||||||
this.markers.push(marker);
|
this.markers.push(marker);
|
||||||
}
|
}
|
||||||
|
@ -113,14 +113,17 @@ export default class MarkerLayer extends EventEmitter {
|
||||||
this.removeAllListeners();
|
this.removeAllListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
private addPoint(marker: IMarker) {
|
private addPoint(marker: IMarker, id: number) {
|
||||||
const { lng, lat } = marker.getLnglat();
|
const { lng, lat } = marker.getLnglat();
|
||||||
const feature: IPointFeature = {
|
const feature: IPointFeature = {
|
||||||
geometry: {
|
geometry: {
|
||||||
type: 'Point',
|
type: 'Point',
|
||||||
coordinates: [lng, lat],
|
coordinates: [lng, lat],
|
||||||
},
|
},
|
||||||
properties: marker.getExtData(),
|
properties: {
|
||||||
|
...marker.getExtData(),
|
||||||
|
marker_id: id,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
this.points.push(feature);
|
this.points.push(feature);
|
||||||
}
|
}
|
||||||
|
@ -200,11 +203,13 @@ export default class MarkerLayer extends EventEmitter {
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
private normalMarker(feature: any) {
|
private normalMarker(feature: any) {
|
||||||
const marker = new Marker().setLnglat({
|
const marker_id = feature.properties.marker_id;
|
||||||
|
return marker_id
|
||||||
|
? new Marker().setLnglat({
|
||||||
lng: feature.geometry.coordinates[0],
|
lng: feature.geometry.coordinates[0],
|
||||||
lat: feature.geometry.coordinates[1],
|
lat: feature.geometry.coordinates[1],
|
||||||
});
|
})
|
||||||
return marker;
|
: this.markers[marker_id];
|
||||||
}
|
}
|
||||||
private update() {
|
private update() {
|
||||||
const zoom = this.mapsService.getZoom();
|
const zoom = this.mapsService.getZoom();
|
||||||
|
|
Loading…
Reference in New Issue