forked from MapComplete/MapComplete
UX: also zoom to appropriate zoom level, see #1938
This commit is contained in:
parent
d4367e017a
commit
69a4ac0261
1 changed files with 7 additions and 4 deletions
|
@ -21,6 +21,7 @@ export default class InitialMapPositioning {
|
||||||
public zoom: UIEventSource<number>
|
public zoom: UIEventSource<number>
|
||||||
public location: UIEventSource<{ lon: number; lat: number }>
|
public location: UIEventSource<{ lon: number; lat: number }>
|
||||||
public useTerrain: Store<boolean>
|
public useTerrain: Store<boolean>
|
||||||
|
|
||||||
constructor(layoutToUse: LayoutConfig, downloader: OsmObjectDownloader) {
|
constructor(layoutToUse: LayoutConfig, downloader: OsmObjectDownloader) {
|
||||||
function localStorageSynced(
|
function localStorageSynced(
|
||||||
key: string,
|
key: string,
|
||||||
|
@ -70,14 +71,16 @@ export default class InitialMapPositioning {
|
||||||
})
|
})
|
||||||
this.useTerrain = new ImmutableStore<boolean>(layoutToUse.enableTerrain)
|
this.useTerrain = new ImmutableStore<boolean>(layoutToUse.enableTerrain)
|
||||||
|
|
||||||
if(initialHash?.match(/^(node|way|relation)\/[0-9]+$/)){
|
if (initialHash?.match(/^(node|way|relation)\/[0-9]+$/)) {
|
||||||
const [type, id] = initialHash.split("/")
|
const [type, id] = initialHash.split("/")
|
||||||
OsmObjectDownloader.RawDownloadObjectAsync(type, Number(id), Constants.osmAuthConfig.url+"/").then(osmObject => {
|
OsmObjectDownloader.RawDownloadObjectAsync(type, Number(id), Constants.osmAuthConfig.url + "/").then(osmObject => {
|
||||||
if(osmObject === "deleted"){
|
if (osmObject === "deleted") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const targetLayer = layoutToUse.getMatchingLayer(osmObject.tags)
|
||||||
|
this.zoom.setData(Math.max(this.zoom.data, targetLayer.minzoom))
|
||||||
const [lat, lon] = osmObject.centerpoint()
|
const [lat, lon] = osmObject.centerpoint()
|
||||||
this.location.setData({lon, lat})
|
this.location.setData({ lon, lat })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue