Add standalone bicycle library theme, search now opens the popup of the found object

This commit is contained in:
Pieter Vander Vennet 2021-01-06 02:09:04 +01:00
parent a35b80afbb
commit c359d43b15
15 changed files with 260 additions and 43 deletions

View file

@ -5,7 +5,8 @@ export class Geocoding {
private static readonly host = "https://nominatim.openstreetmap.org/search?";
static Search(query: string,
handleResult: ((places: { display_name: string, lat: number, lon: number, boundingbox: number[] }[]) => void),
handleResult: ((places: { display_name: string, lat: number, lon: number, boundingbox: number[],
osm_type: string, osm_id: string}[]) => void),
onFail: (() => void)) {
const b = State.state.leafletMap.data.getBounds();
console.log(b);

View file

@ -454,19 +454,19 @@ export class TagUtils {
static MatchesMultiAnswer(tag: TagsFilter, tags: any): boolean {
const splitted = TagUtils.SplitKeys([tag]);
console.log("Matching multianswer", tag, tags)
for (const splitKey in splitted) {
const neededValues = splitted[splitKey];
if(tags[splitKey] === undefined) {
return false;
}
const actualValue = tags[splitKey].split(";");
for (const neededValue of neededValues) {
console.log("needed", neededValue, "have: ", actualValue, actualValue.indexOf(neededValue) )
if (actualValue.indexOf(neededValue) < 0) {
console.log("NOT FOUND")
return false;
}
}
}
console.log("OK")
return true;
}
}

View file

@ -2,11 +2,17 @@ import {UIEventSource} from "../UIEventSource";
export default class Hash {
public static Get() : UIEventSource<string>{
public static hash : UIEventSource<string> = Hash.Get();
private static Get() : UIEventSource<string>{
const hash = new UIEventSource<string>(window.location.hash.substr(1));
hash.addCallback(h => {
if(h === undefined || h === ""){
window.location.hash = "";
return;
}
h = h.replace(/\//g, "_");
return window.location.hash = "#" + h;
window.location.hash = "#" + h;
});
window.onhashchange = () => {
hash.setData(window.location.hash.substr(1))

View file

@ -62,7 +62,7 @@ export class QueryParameters {
parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(QueryParameters.knownSources[key].data))
}
history.replaceState(null, "", "?" + parts.join("&") + "#" + Hash.Get().data);
history.replaceState(null, "", "?" + parts.join("&") + "#" + Hash.hash.data);
}