Add search, a few flow updates

This commit is contained in:
Pieter Vander Vennet 2020-07-01 02:12:33 +02:00
parent 7b9ab77bda
commit c87c014045
14 changed files with 345 additions and 17 deletions

View file

@ -191,9 +191,15 @@ export class FilteredLayer {
layer.on("click", function(e) {
console.log("Selected ", feature)
self._selectedElement.setData(feature.properties);
L.DomEvent.stop(e); // Marks the event as consumed
const uiElement = self._showOnPopup.data();
layer.bindPopup(uiElement.Render()).openPopup();
const popup = L.popup();
popup.setContent(uiElement.Render());
layer.bindPopup(popup).openPopup();
popup.onclose(() => {
layer.removePopup(popup)
});
uiElement.Update();
uiElement.Activate();

18
Logic/Geocoding.ts Normal file
View file

@ -0,0 +1,18 @@
import * as $ from "jquery"
import {UIEventSource} from "../UI/UIEventSource";
export class Geocoding {
private static readonly host = "https://nominatim.openstreetmap.org/search?";
static Search(query: string, currentLocation: UIEventSource<{ lat: number, lon: number }>,
handleResult: ((places: { display_name: string, lat: number, lon: number, boundingbox : number[] }[]) => void)) {
$.getJSON(
Geocoding.host + "format=json&accept-language=nl&q=" + query,
function (data) {
handleResult(data);
});
}
}

View file

@ -24,6 +24,7 @@ export class StrayClickHandler {
const self = this;
const map = basemap.map;
basemap.LastClickLocation.addCallback(function (lastClick) {
selectElement.setData(undefined);
if (self._lastMarker !== undefined) {
map.removeLayer(self._lastMarker);
@ -36,8 +37,9 @@ export class StrayClickHandler {
self._lastMarker.addTo(map);
self._lastMarker.bindPopup(popup).openPopup();
leftMessage.setData(self._uiToShow);
self._lastMarker.on("click", () => {
leftMessage.setData(self._uiToShow);
});
});