mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
MapWidget.qml: try to preserve zoom when opening Google Maps
Extend openLocationInGoogleMaps() so that the current map widget zoom level is roughly mapped to the Google Maps zoom level. The two zoom scales are quite different. Google Maps uses meters directly, while the QML map uses a scale from ~1 - 21. The approximation is done via exponential regression over a small data set gathered from experiment. Add a console.log() call so that the URL is logged. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
16b3892f22
commit
64e2247aa7
1 changed files with 24 additions and 1 deletions
|
@ -324,10 +324,33 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* open coordinates in google maps while attempting to roughly preserve
|
||||
* the zoom level. the mapping between the QML map zoom level and the
|
||||
* Google Maps zoom level is done via exponential regression:
|
||||
* y = a * exp(b * x)
|
||||
*
|
||||
* data set:
|
||||
* qml (x) gmaps (y in meters)
|
||||
* 21 257
|
||||
* 15.313216749178913 3260
|
||||
* 12.553216749178931 20436
|
||||
* 11.11321674917894 52883
|
||||
* 9.313216749178952 202114
|
||||
* 7.51321674917896 737136
|
||||
* 5.593216749178958 2495529
|
||||
* 4.153216749178957 3895765
|
||||
* 1.753216749178955 18999949
|
||||
*/
|
||||
function openLocationInGoogleMaps(latitude, longitude) {
|
||||
var loc = latitude + "," + longitude
|
||||
var url = "https://www.google.com/maps/place/@" + loc + ",5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0"
|
||||
var x = map.zoomLevel
|
||||
var a = 53864950.831693
|
||||
var b = -0.60455861606547030630
|
||||
var zoom = Math.floor(a * Math.exp(b * x))
|
||||
var url = "https://www.google.com/maps/place/@" + loc + "," + zoom + "m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0"
|
||||
Qt.openUrlExternally(url)
|
||||
console.log("openLocationInGoogleMaps() map.zoomLevel: " + x + ", url: " + url)
|
||||
}
|
||||
|
||||
MapWidgetContextMenu {
|
||||
|
|
Loading…
Add table
Reference in a new issue