OsmObjects can now be used as featureSource, load selected object immediately, zoom to selected object on open; fix #191

This commit is contained in:
Pieter Vander Vennet 2021-05-06 01:33:09 +02:00
parent 5ce4140510
commit a0c1bc2137
13 changed files with 205 additions and 98 deletions

View file

@ -0,0 +1,21 @@
import FeatureSource from "./FeatureSource";
import {UIEventSource} from "../UIEventSource";
import {OsmObject} from "../Osm/OsmObject";
export default class OsmApiFeatureSource implements FeatureSource {
public readonly features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{ feature: any; freshness: Date }[]>([]);
public readonly name: string = "OsmApiFeatureSource";
public load(id: string){
console.log("Updating from OSM API: ", id)
OsmObject.DownloadObject(id, (element, meta) => {
const geojson = element.asGeoJson();
console.warn(geojson)
geojson.id = geojson.properties.id;
this.features.setData([{feature:geojson, freshness: meta["_last_edit:timestamp"]}])
})
}
}