mirror of https://gitee.com/antv-l7/antv-l7
improvement(component): 支持不显示视野外的Marker
This commit is contained in:
parent
85abfaee77
commit
e75fdc98b1
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue