@antv/l7-component
Advanced tools
Comparing version 2.0.18 to 2.0.19
@@ -31,2 +31,3 @@ import { IMarker } from '@antv/l7-core'; | ||
private zoom; | ||
private bbox; | ||
constructor(option?: Partial<IMarkerLayerOption>); | ||
@@ -33,0 +34,0 @@ getDefault(): { |
@@ -15,3 +15,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import { TYPES } from '@antv/l7-core'; | ||
import { bindAll, DOM, Satistics } from '@antv/l7-utils'; | ||
import { bindAll, boundsContains, DOM, padBounds, Satistics } from '@antv/l7-utils'; | ||
import { EventEmitter } from 'eventemitter3'; | ||
@@ -40,2 +40,3 @@ import Supercluster from 'supercluster'; | ||
_this.zoom = void 0; | ||
_this.bbox = void 0; | ||
_this.markerLayerOption = _merge(_this.getDefault(), option); | ||
@@ -71,4 +72,3 @@ bindAll(['update'], _assertThisInitialized(_this)); | ||
this.update(); | ||
this.mapsService.on('zoom', this.update); | ||
this.mapsService.on('zoomchange', this.update); | ||
this.mapsService.on('camerachange', this.update); | ||
} | ||
@@ -121,4 +121,3 @@ | ||
}); | ||
this.mapsService.off('zoom', this.update); | ||
this.mapsService.off('zoomchange', this.update); | ||
this.mapsService.off('camerachange', this.update); | ||
this.markers = []; | ||
@@ -171,6 +170,7 @@ } | ||
key: "getClusterMarker", | ||
value: function getClusterMarker(zoom) { | ||
value: function getClusterMarker(viewBounds, zoom) { | ||
var _this3 = this; | ||
var clusterPoint = this.clusterIndex.getClusters([-180, -85, 180, 85], zoom); | ||
var viewBBox = viewBounds[0].concat(viewBounds[1]); | ||
var clusterPoint = this.clusterIndex.getClusters(viewBBox, zoom); | ||
this.clusterMarkers.forEach(function (marker) { | ||
@@ -203,3 +203,3 @@ marker.remove(); | ||
var fieldName = 'point_' + method; | ||
feature.properties[fieldName] = stat; | ||
feature.properties[fieldName] = stat.toFixed(2); | ||
} | ||
@@ -252,6 +252,8 @@ } | ||
var zoom = this.mapsService.getZoom(); | ||
var bbox = this.mapsService.getBounds(); | ||
if (Math.abs(zoom - this.zoom) > 1) { | ||
this.getClusterMarker(Math.floor(zoom)); | ||
if (!this.bbox || Math.abs(zoom - this.zoom) >= 1 || !boundsContains(this.bbox, bbox)) { | ||
this.bbox = padBounds(bbox, 0.5); | ||
this.zoom = Math.floor(zoom); | ||
this.getClusterMarker(this.bbox, this.zoom); | ||
} | ||
@@ -258,0 +260,0 @@ } |
@@ -58,2 +58,3 @@ "use strict"; | ||
_this.zoom = void 0; | ||
_this.bbox = void 0; | ||
_this.markerLayerOption = (0, _merge2.default)(_this.getDefault(), option); | ||
@@ -89,4 +90,3 @@ (0, _l7Utils.bindAll)(['update'], (0, _assertThisInitialized2.default)(_this)); | ||
this.update(); | ||
this.mapsService.on('zoom', this.update); | ||
this.mapsService.on('zoomchange', this.update); | ||
this.mapsService.on('camerachange', this.update); | ||
} | ||
@@ -139,4 +139,3 @@ | ||
}); | ||
this.mapsService.off('zoom', this.update); | ||
this.mapsService.off('zoomchange', this.update); | ||
this.mapsService.off('camerachange', this.update); | ||
this.markers = []; | ||
@@ -189,6 +188,7 @@ } | ||
key: "getClusterMarker", | ||
value: function getClusterMarker(zoom) { | ||
value: function getClusterMarker(viewBounds, zoom) { | ||
var _this3 = this; | ||
var clusterPoint = this.clusterIndex.getClusters([-180, -85, 180, 85], zoom); | ||
var viewBBox = viewBounds[0].concat(viewBounds[1]); | ||
var clusterPoint = this.clusterIndex.getClusters(viewBBox, zoom); | ||
this.clusterMarkers.forEach(function (marker) { | ||
@@ -223,3 +223,3 @@ marker.remove(); | ||
var fieldName = 'point_' + method; | ||
feature.properties[fieldName] = stat; | ||
feature.properties[fieldName] = stat.toFixed(2); | ||
} | ||
@@ -272,6 +272,8 @@ } | ||
var zoom = this.mapsService.getZoom(); | ||
var bbox = this.mapsService.getBounds(); | ||
if (Math.abs(zoom - this.zoom) > 1) { | ||
this.getClusterMarker(Math.floor(zoom)); | ||
if (!this.bbox || Math.abs(zoom - this.zoom) >= 1 || !(0, _l7Utils.boundsContains)(this.bbox, bbox)) { | ||
this.bbox = (0, _l7Utils.padBounds)(bbox, 0.5); | ||
this.zoom = Math.floor(zoom); | ||
this.getClusterMarker(this.bbox, this.zoom); | ||
} | ||
@@ -278,0 +280,0 @@ } |
{ | ||
"name": "@antv/l7-component", | ||
"version": "2.0.18", | ||
"version": "2.0.19", | ||
"description": "", | ||
@@ -27,4 +27,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@antv/l7-core": "^2.0.18", | ||
"@antv/l7-utils": "^2.0.18", | ||
"@antv/l7-core": "^2.0.19", | ||
"@antv/l7-utils": "^2.0.19", | ||
"@babel/runtime": "^7.7.7", | ||
@@ -35,3 +35,3 @@ "eventemitter3": "^4.0.0", | ||
}, | ||
"gitHead": "3d301ac08dba08d8d0ebc8043d1a72df78505cd1", | ||
"gitHead": "4174d5a421cc4bc127df7b8cc31b0c871adfe4fa", | ||
"publishConfig": { | ||
@@ -38,0 +38,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
380523
3781
Updated@antv/l7-core@^2.0.19
Updated@antv/l7-utils@^2.0.19