forked from MapComplete/MapComplete
First working version of snapping to already existing ways from the add-UI (still too slow though), partial fix of #436
This commit is contained in:
parent
bf2d634208
commit
0a01561d37
15 changed files with 460 additions and 143 deletions
|
@ -16,9 +16,9 @@ export default class ShowDataLayer {
|
|||
private readonly _leafletMap: UIEventSource<L.Map>;
|
||||
private _cleanCount = 0;
|
||||
private readonly _enablePopups: boolean;
|
||||
private readonly _features: UIEventSource<{ feature: any}[]>
|
||||
private readonly _features: UIEventSource<{ feature: any }[]>
|
||||
|
||||
constructor(features: UIEventSource<{ feature: any}[]>,
|
||||
constructor(features: UIEventSource<{ feature: any }[]>,
|
||||
leafletMap: UIEventSource<L.Map>,
|
||||
layoutToUse: UIEventSource<LayoutConfig>,
|
||||
enablePopups = true,
|
||||
|
@ -85,7 +85,9 @@ export default class ShowDataLayer {
|
|||
console.error(e)
|
||||
}
|
||||
}
|
||||
State.state.selectedElement.ping()
|
||||
if (self._enablePopups) {
|
||||
State.state.selectedElement.ping()
|
||||
}
|
||||
}
|
||||
|
||||
features.addCallback(() => update());
|
||||
|
@ -106,13 +108,12 @@ export default class ShowDataLayer {
|
|||
// We have to convert them to the appropriate icon
|
||||
// Click handling is done in the next step
|
||||
|
||||
const tagSource = State.state.allElements.getEventSourceById(feature.properties.id)
|
||||
const layer: LayerConfig = this._layerDict[feature._matching_layer_id];
|
||||
|
||||
if (layer === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tagSource = feature.properties.id === undefined ? new UIEventSource<any>(feature.properties) : State.state.allElements.getEventSourceById(feature.properties.id)
|
||||
const style = layer.GenerateLeafletStyle(tagSource, !(layer.title === undefined && (layer.tagRenderings ?? []).length === 0));
|
||||
const baseElement = style.icon.html;
|
||||
if (!this._enablePopups) {
|
||||
|
@ -146,8 +147,8 @@ export default class ShowDataLayer {
|
|||
autoPan: true,
|
||||
closeOnEscapeKey: true,
|
||||
closeButton: false,
|
||||
autoPanPaddingTopLeft: [15,15],
|
||||
|
||||
autoPanPaddingTopLeft: [15, 15],
|
||||
|
||||
}, leafletLayer);
|
||||
|
||||
leafletLayer.bindPopup(popup);
|
||||
|
@ -191,7 +192,7 @@ export default class ShowDataLayer {
|
|||
) {
|
||||
leafletLayer.openPopup()
|
||||
}
|
||||
if(feature.id !== feature.properties.id){
|
||||
if (feature.id !== feature.properties.id) {
|
||||
console.trace("Not opening the popup for", feature)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue