[gnome-maps] mapView: Check coords and zoom level before setting
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] mapView: Check coords and zoom level before setting
- Date: Sun, 25 Aug 2019 09:22:18 +0000 (UTC)
commit 88ea42af389ebac1debbabb4d399f2dc752ce40b
Author: Marcus Lundblad <ml update uu se>
Date: Sun Aug 25 11:21:04 2019 +0200
mapView: Check coords and zoom level before setting
Sanity-check last coordinates and zoom level
before trying to set them on the view.
Fixes #196
src/mapView.js | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 80fdeda..5d030ac 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -496,8 +496,20 @@ var MapView = GObject.registerClass({
let location = Application.settings.get('last-viewed-location');
if (location.length === 2) {
- this.view.zoom_level = Application.settings.get('zoom-level');
- this.view.center_on(location[0], location[1]);
+ let [lat, lon] = location;
+ let zoom = Application.settings.get('zoom-level');
+
+ if (zoom >= this.view.min_zoom_level &&
+ zoom <= this.view.max_zoom_level)
+ this.view.zoom_level = Application.settings.get('zoom-level');
+ else
+ Utils.debug('Invalid initial zoom level: ' + zoom);
+
+ if (lat >= MIN_LATITUDE && lat <= MAX_LATITUDE &&
+ lon >= MIN_LONGITUDE && lon <= MAX_LONGITUDE)
+ this.view.center_on(location[0], location[1]);
+ else
+ Utils.debug('Invalid initial coordinates: ' + lat + ', ' + lon);
} else {
/* bounding box. for backwards compatibility, not used anymore */
let bbox = new Champlain.BoundingBox({ top: location[0],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]