mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mapwidget.qml: add a couple of helpers
Add stopZoomAnimations(), which is really just a precaution function to make sure we have stopped all animation of the map before doing calculations! Since the animation *should* be running in a separate thread, this would make sure the Map "center" and "zoomLevel" properties do not change. Add pointIsVisible(), which is a helper to determine if a point created by map.fromCoordinate() method is inside the viewport. fromCoordinate() has to be called without the "false" (clip) flag for this to work. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
d421660f91
commit
0fc9a3bf4a
1 changed files with 12 additions and 2 deletions
|
@ -148,7 +148,17 @@ Item {
|
|||
mapAnimationZoomOut.restart()
|
||||
}
|
||||
|
||||
function pointIsVisible(pt) {
|
||||
return !isNaN(pt.x)
|
||||
}
|
||||
|
||||
function stopZoomAnimations() {
|
||||
mapAnimationZoomIn.stop()
|
||||
mapAnimationZoomOut.stop()
|
||||
}
|
||||
|
||||
function centerOnCoordinate(coord) {
|
||||
stopZoomAnimations()
|
||||
newCenter = coord
|
||||
if (coord.latitude === 0.0 && coord.longitude === 0.0) {
|
||||
newZoom = 2.6
|
||||
|
@ -157,8 +167,8 @@ Item {
|
|||
var zoomStored = zoomLevel
|
||||
newZoomOut = zoomLevel
|
||||
while (zoomLevel > minimumZoomLevel) {
|
||||
var pt = fromCoordinate(coord, false)
|
||||
if (pt.x > 0 && pt.y > 0 && pt.x < width && pt.y < height) {
|
||||
var pt = fromCoordinate(coord)
|
||||
if (pointIsVisible(pt)) {
|
||||
newZoomOut = zoomLevel
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue