mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-05-06 08:26:40 +07:00
added map fitting
This commit is contained in:
parent
0314edd550
commit
bc34cf3876
12 changed files with 93 additions and 78 deletions
src/constants
|
@ -1,6 +1,12 @@
|
|||
import { Map } from 'leaflet';
|
||||
import { Map, LayerGroup, Layer, FeatureGroup } from 'leaflet';
|
||||
|
||||
export class MapContainer extends Map {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.routeLayer.addTo(this);
|
||||
this.stickerLayer.addTo(this);
|
||||
}
|
||||
|
||||
disableClicks = () => {
|
||||
this.clickable = false;
|
||||
};
|
||||
|
@ -9,10 +15,23 @@ export class MapContainer extends Map {
|
|||
this.clickable = true;
|
||||
};
|
||||
|
||||
getVisibleBounds = () => {
|
||||
const layers = [this.routeLayer, this.stickerLayer];
|
||||
for (let i = 0; i < layers.length; i += 1) {
|
||||
const bounds = layers[i].getBounds();
|
||||
if (Object.keys(bounds).length == 2) return bounds;
|
||||
}
|
||||
};
|
||||
|
||||
public clickable = true;
|
||||
|
||||
public routeLayer = new FeatureGroup();
|
||||
public stickerLayer = new FeatureGroup();
|
||||
}
|
||||
|
||||
export const MainMap = new MapContainer(document.getElementById('canvas')).setView(
|
||||
[55.0153275, 82.9071235],
|
||||
13
|
||||
);
|
||||
|
||||
console.log('MAP', MainMap);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue