[gnome-maps/wip/mark-user-location] show accuracy
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mark-user-location] show accuracy
- Date: Mon, 8 Apr 2013 18:47:05 +0000 (UTC)
commit a91926bf0180532779fe24ad4b10865ece03be79
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Apr 8 20:05:14 2013 +0300
show accuracy
src/mapView.js | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index fe5ecef..bd8f481 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -23,6 +23,7 @@ const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Champlain = imports.gi.Champlain;
const Geocode = imports.gi.GeocodeGlib;
+const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@@ -51,6 +52,10 @@ const MapView = new Lang.Class({
this._markerLayer.set_selection_mode(Champlain.SelectionMode.SINGLE);
this._view.add_layer(this._markerLayer);
+ this._pointLayer = new Champlain.MarkerLayer();
+ this._pointLayer.set_selection_mode(Champlain.SelectionMode.SINGLE);
+ this._view.add_layer(this._pointLayer);
+
this._factory = Champlain.MapSourceFactory.dup_default();
this.setMapType(MapType.STREET);
@@ -102,6 +107,38 @@ const MapView = new Lang.Class({
this._view.go_to(location.latitude, location.longitude);
},
+ _showUserLocation: function (location) {
+ if (location.accuracy <= 0)
+ return;
+
+ this._pointLayer.remove_all();
+ let point = new Champlain.Point();
+ point.set_color(new Clutter.Color({ red: 0,
+ blue: 255,
+ green: 0,
+ alpha: 50 }));
+ point.set_location(location.latitude, location.longitude);
+
+ let allocSize = Lang.bind(this,
+ function(zoom) {
+ let source = this._view.get_map_source();
+ let metersPerPixel = source.get_meters_per_pixel(zoom, location.latitude,
location.longitude);
+ point.set_size(location.accuracy / metersPerPixel);
+ });
+ let zoom = Utils.getZoomLevelForAccuracy(location.accuracy);
+ allocSize(zoom);
+ this._pointLayer.add_marker(point);
+
+ this._view.connect_after("layer-relocated", Lang.bind(this,
+ function() {
+ print ("layer relocated starts");
+ let zoom = this._view.get_zoom_level();
+ print ("allocating size");
+ allocSize(zoom);
+ print ("layer relocated ends");
+ }));
+ },
+
_gotoUserLocation: function () {
let lastLocation = Application.settings.get_value('last-location');
if (lastLocation.n_children() >= 3) {
@@ -116,6 +153,7 @@ const MapView = new Lang.Class({
location.set_description(lastLocationDescription);
this._gotoLocation(location, false);
+ this._showUserLocation(location);
}
let ipclient = new Geocode.Ipclient();
@@ -127,6 +165,7 @@ const MapView = new Lang.Class({
let location = ipclient.search_finish(res);
this._gotoLocation(location, true);
+ this._showUserLocation(location);
let variant = GLib.Variant.new('ad', [location.latitude, location.longitude,
location.accuracy]);
Application.settings.set_value('last-location', variant);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]