[gnome-maps/wip/fix-geoloc: 4/11] MapLocation: move zoomToFit-functionality
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/fix-geoloc: 4/11] MapLocation: move zoomToFit-functionality
- Date: Wed, 24 Jul 2013 05:58:07 +0000 (UTC)
commit 9d662455dcc001034c24bcc8bd4ef48734e104c3
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Wed Jul 10 18:22:34 2013 +0200
MapLocation: move zoomToFit-functionality
Move and rename zoom to fit-functionality to MapLocation since it's
probably not very general anyways.
https://bugzilla.gnome.org/show_bug.cgi?id=704537
src/mapLocation.js | 24 ++++++++++++++++++++----
src/utils.js | 15 ---------------
2 files changed, 20 insertions(+), 19 deletions(-)
---
diff --git a/src/mapLocation.js b/src/mapLocation.js
index e7e98f1..1312984 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -47,11 +47,9 @@ const MapLocation = new Lang.Class({
goTo: function(animate) {
log("Going to " + this.description);
- let zoom = Utils.getZoomLevelForAccuracy(this.accuracy);
-
if (!animate) {
this._view.center_on(this.latitude, this.longitude);
- this._view.set_zoom_level(zoom);
+ this.zoomToFit();
this.emit('gone-to');
return;
@@ -70,7 +68,7 @@ const MapLocation = new Lang.Class({
id = this._view.connect("animation-completed::go-to", (function() {
this._view.disconnect(id);
- this._view.set_zoom_level(zoom);
+ this.zoomToFit();
this.emit('gone-to');
}).bind(this));
@@ -92,6 +90,24 @@ const MapLocation = new Lang.Class({
this.goTo(animate);
},
+ // Zoom to the maximal zoom-level that fits the accuracy circle
+ zoomToFit: function() {
+ let zoom;
+ if (this.accuracy === Geocode.LOCATION_ACCURACY_UNKNOWN)
+ zoom = 12; // Accuracy is usually city-level when unknown
+ else if (this.accuracy <= Geocode.LOCATION_ACCURACY_STREET)
+ zoom = 16;
+ else if (this.accuracy <= Geocode.LOCATION_ACCURACY_CITY)
+ zoom = 12;
+ else if (this.accuracy <= Geocode.LOCATION_ACCURACY_REGION)
+ zoom = 10;
+ else if (this.accuracy <= Geocode.LOCATION_ACCURACY_COUNTRY)
+ zoom = 6;
+ else
+ zoom = 3;
+ this._view.set_zoom_level(zoom);
+ },
+
_getCurrentLocation: function() {
return new Geocode.Location({
latitude: this._view.get_center_latitude(),
diff --git a/src/utils.js b/src/utils.js
index 07af316..f125702 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -79,21 +79,6 @@ function initActions(actionMap, simpleActionEntries, context) {
});
}
-// accuracy: double value in meters
-function getZoomLevelForAccuracy(accuracy) {
- if (accuracy == Geocode.LOCATION_ACCURACY_UNKNOWN)
- return 12; // Accuracy is usually city-level when unknown
- else if (accuracy <= Geocode.LOCATION_ACCURACY_STREET)
- return 16;
- else if (accuracy <= Geocode.LOCATION_ACCURACY_CITY)
- return 12;
- else if (accuracy <= Geocode.LOCATION_ACCURACY_REGION)
- return 10;
- else if (accuracy <= Geocode.LOCATION_ACCURACY_COUNTRY)
- return 6;
- else
- return 3;
-}
function getDescriptionForAccuracy(accuracy) {
if (accuracy == Geocode.LOCATION_ACCURACY_UNKNOWN)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]