improvement(component): 支持不显示视野外的Marker

This commit is contained in:
thinkinggis 2020-04-22 17:39:10 +08:00
parent 85abfaee77
commit e75fdc98b1
2 changed files with 14 additions and 12 deletions

View File

@ -221,18 +221,20 @@ export default class Marker extends EventEmitter {
const { element, offsets } = this.markerOption;
const { lng, lat } = this.lngLat;
const bounds = this.mapsService.getBounds();
// if (
// lng < bounds[0][0] ||
// lng > bounds[1][0] ||
// lat < bounds[0][1] ||
// lat > bounds[1][1]
// ) {
// if (element) {
// element.style.display = 'none';
// }
const zoom = this.mapsService.getZoom();
if (
(lng < bounds[0][0] ||
lng > bounds[1][0] ||
lat < bounds[0][1] ||
lat > bounds[1][1]) &&
zoom > 3
) {
if (element) {
element.style.display = 'none';
}
// return;
// }
return;
}
const pos = this.mapsService.lngLatToContainer([lng, lat]);
if (element) {
element.style.display = 'block';

View File

@ -1,6 +1,6 @@
// @ts-ignore
import { Marker, MarkerLayer, PolygonLayer, Scene } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react';
export default class MarkerLayerComponent extends React.Component {
private scene: Scene;