forked from MapComplete/MapComplete
OsmObjects can now be used as featureSource, load selected object immediately, zoom to selected object on open; fix #191
This commit is contained in:
parent
5ce4140510
commit
a0c1bc2137
13 changed files with 205 additions and 98 deletions
21
Logic/FeatureSource/OsmApiFeatureSource.ts
Normal file
21
Logic/FeatureSource/OsmApiFeatureSource.ts
Normal 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"]}])
|
||||
})
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue