mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
fixed bound fitting
This commit is contained in:
parent
acedb845af
commit
4416fa5d64
4 changed files with 33 additions and 16 deletions
|
@ -357,10 +357,25 @@ export class Editor {
|
||||||
};
|
};
|
||||||
|
|
||||||
fitDrawing = (): void => {
|
fitDrawing = (): void => {
|
||||||
if (this.poly.isEmpty) return;
|
if (!this.poly.isEmpty) {
|
||||||
|
const poly_bounds = this.poly.poly.getBounds();
|
||||||
|
|
||||||
const bounds = this.poly.poly.getBounds();
|
if (poly_bounds && Object.values(poly_bounds).length) {
|
||||||
if (bounds && Object.values(bounds)) this.map.map.fitBounds(bounds);
|
this.map.map.fitBounds(poly_bounds);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.stickers.isEmpty) {
|
||||||
|
const stickers_bounds = this.stickers.layer.getBounds();
|
||||||
|
|
||||||
|
if (stickers_bounds && Object.values(stickers_bounds).length) {
|
||||||
|
this.map.map.fitBounds(stickers_bounds);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no bounds to fit. better do something later
|
||||||
};
|
};
|
||||||
|
|
||||||
setInitialData = (): void => {
|
setInitialData = (): void => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { LayerGroup, layerGroup, Map } from 'leaflet';
|
import {FeatureGroup, LayerGroup, layerGroup, Map} from 'leaflet';
|
||||||
import { IStickerDump, Sticker } from '$modules/Sticker';
|
import { IStickerDump, Sticker } from '$modules/Sticker';
|
||||||
import { MarkerClusterGroup } from 'leaflet.markercluster/dist/leaflet.markercluster-src.js';
|
import { MarkerClusterGroup } from 'leaflet.markercluster/dist/leaflet.markercluster-src.js';
|
||||||
import { clusterIcon } from '$utils/clusterIcon';
|
import { clusterIcon } from '$utils/clusterIcon';
|
||||||
|
@ -24,8 +24,7 @@ export class Stickers {
|
||||||
this.triggerOnChange = triggerOnChange;
|
this.triggerOnChange = triggerOnChange;
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
|
|
||||||
this.clusterLayer.addTo(map);
|
// this.clusterLayer.addTo(map);
|
||||||
|
|
||||||
// this.clusterLayer.on('animationend', this.onSpiderify);
|
// this.clusterLayer.on('animationend', this.onSpiderify);
|
||||||
|
|
||||||
this.lockMapClicks = lockMapClicks;
|
this.lockMapClicks = lockMapClicks;
|
||||||
|
@ -55,7 +54,7 @@ export class Stickers {
|
||||||
|
|
||||||
this.stickers.push(marker);
|
this.stickers.push(marker);
|
||||||
|
|
||||||
marker.marker.addTo(this.clusterLayer);
|
marker.marker.addTo(this.layer);
|
||||||
|
|
||||||
this.triggerOnChange();
|
this.triggerOnChange();
|
||||||
};
|
};
|
||||||
|
@ -65,7 +64,8 @@ export class Stickers {
|
||||||
|
|
||||||
if (index < 0) return;
|
if (index < 0) return;
|
||||||
|
|
||||||
this.clusterLayer.removeLayer(ref.marker);
|
// this.clusterLayer.removeLayer(ref.marker);
|
||||||
|
this.layer.removeLayer(ref.marker);
|
||||||
this.stickers.splice(index, 1);
|
this.stickers.splice(index, 1);
|
||||||
|
|
||||||
this.triggerOnChange();
|
this.triggerOnChange();
|
||||||
|
@ -89,7 +89,10 @@ export class Stickers {
|
||||||
this.stickers.map(sticker => sticker.stopEditing());
|
this.stickers.map(sticker => sticker.stopEditing());
|
||||||
};
|
};
|
||||||
|
|
||||||
clusterLayer: LayerGroup = new LayerGroup();
|
get isEmpty(): boolean {
|
||||||
|
return !this.stickers || this.stickers.length === 0
|
||||||
|
};
|
||||||
|
// clusterLayer: LayerGroup = new LayerGroup();
|
||||||
|
|
||||||
// uncomment to enable clustering
|
// uncomment to enable clustering
|
||||||
|
|
||||||
|
@ -106,9 +109,8 @@ export class Stickers {
|
||||||
editor: Props['editor'];
|
editor: Props['editor'];
|
||||||
map: Props['map'];
|
map: Props['map'];
|
||||||
|
|
||||||
|
|
||||||
stickers: Array<Sticker> = [];
|
stickers: Array<Sticker> = [];
|
||||||
layer: LayerGroup = layerGroup();
|
layer: FeatureGroup = new FeatureGroup();
|
||||||
|
|
||||||
triggerOnChange: Props['triggerOnChange'];
|
triggerOnChange: Props['triggerOnChange'];
|
||||||
lockMapClicks: Props['lockMapClicks'];
|
lockMapClicks: Props['lockMapClicks'];
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
@red_primary: #ff7034;
|
@red_primary: #ff7034;
|
||||||
@red_secondary: #ff3344;
|
@red_secondary: #ff3344;
|
||||||
|
|
||||||
@panel_radius: 2px;
|
@panel_radius: 6px;
|
||||||
@button_radius: 2px;
|
@button_radius: 6px;
|
||||||
|
|
||||||
@color_primary: #4597d0;
|
@color_primary: #4597d0;
|
||||||
@color_success: #7cd766;
|
@color_success: #7cd766;
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.control-sep {
|
.control-sep {
|
||||||
height: 44px;
|
height: 36px;
|
||||||
background: #222222;
|
background: #222222;
|
||||||
width: 3px;
|
width: 6px;
|
||||||
|
|
||||||
@media (max-width: @mobile_breakpoint) {
|
@media (max-width: @mobile_breakpoint) {
|
||||||
margin-left: -1px;
|
margin-left: -1px;
|
||||||
margin-right: -1px;
|
margin-right: -1px;
|
||||||
width: 4px;
|
width: 6px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue