[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: Fri, 19 Jul 2013 12:43:40 +0000 (UTC)
commit a73f18b2bfa3d9b20b43cae3ae0aa57b7cce5db3
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 | 26 ++++++++++++++++++++++----
src/utils.js | 15 ---------------
2 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/src/mapLocation.js b/src/mapLocation.js
index e7e98f1..4d3aa48 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,26 @@ 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 95f2292..817ef39 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -86,21 +86,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]