[gnome-maps] mapView: Show pin on user location



commit 599569c20cd8bbf230068fbc3c945a5d222f34c3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Apr 9 17:52:34 2013 +0300

    mapView: Show pin on user location

 data/icons/Makefile.am |    5 +
 data/icons/pin.svg     |  336 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/mapView.js         |   35 +++++-
 src/path.js.in         |    2 +-
 4 files changed, 376 insertions(+), 2 deletions(-)
---
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index 47eb016..1fbb2fd 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -13,6 +13,11 @@ public_icons =                                       \
        hicolor_apps_256x256_gnome-maps.png     \
        $(NULL)
 
+imagesdir = $(datadir)/gnome-maps/pixmaps
+images_DATA =                                   \
+       pin.svg                                 \
+        $(NULL)
+
 noinst_DATA =                                  \
        gnome-maps.svg                          \
        $(NULL)
diff --git a/data/icons/pin.svg b/data/icons/pin.svg
new file mode 100644
index 0000000..0acdde2
--- /dev/null
+++ b/data/icons/pin.svg
@@ -0,0 +1,336 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="32px"
+   height="32px"
+   id="svg6019"
+   version="1.1"
+   inkscape:version="0.48.4 r9939"
+   sodipodi:docname="New document 2">
+  <defs
+     id="defs6021">
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6936">
+      <stop
+         style="stop-color:#888a85;stop-opacity:1;"
+         offset="0"
+         id="stop6938" />
+      <stop
+         style="stop-color:#d4d4d2;stop-opacity:1"
+         offset="1"
+         id="stop6940" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6924">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0"
+         offset="0"
+         id="stop6926" />
+      <stop
+         id="stop6932"
+         offset="0.45113504"
+         style="stop-color:#ffffff;stop-opacity:0.54509804;" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0;"
+         offset="1"
+         id="stop6928" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6914">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop6916" />
+      <stop
+         style="stop-color:#000000;stop-opacity:0;"
+         offset="1"
+         id="stop6918" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6869">
+      <stop
+         style="stop-color:#4d0000;stop-opacity:1"
+         offset="0"
+         id="stop6871" />
+      <stop
+         style="stop-color:#540000;stop-opacity:1"
+         offset="1"
+         id="stop6873" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6859">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop6861" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0;"
+         offset="1"
+         id="stop6863" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6841">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop6843" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0;"
+         offset="1"
+         id="stop6845" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6031">
+      <stop
+         style="stop-color:#ff5757;stop-opacity:1"
+         offset="0"
+         id="stop6033" />
+      <stop
+         style="stop-color:#c90000;stop-opacity:1"
+         offset="1"
+         id="stop6035" />
+    </linearGradient>
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6031"
+       id="radialGradient6037"
+       cx="14.702265"
+       cy="10.82002"
+       fx="14.702265"
+       fy="10.82002"
+       r="11.097416"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1.0827713,0,8.6406e-7,1,-1.2169342,1.7279646e-8)" />
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6031-3"
+       id="radialGradient6037-8"
+       cx="14.702265"
+       cy="10.82002"
+       fx="14.702265"
+       fy="10.82002"
+       r="11.097416"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1.0827713,0,8.6406e-7,1,-1.2169342,1.7279646e-8)" />
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6031-3">
+      <stop
+         style="stop-color:#ff5757;stop-opacity:1"
+         offset="0"
+         id="stop6033-4" />
+      <stop
+         style="stop-color:#c90000;stop-opacity:1"
+         offset="1"
+         id="stop6035-0" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6841"
+       id="linearGradient6847"
+       x1="16.789011"
+       y1="4.3640823"
+       x2="16.789011"
+       y2="21.97056"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6859"
+       id="linearGradient6865"
+       x1="16.751778"
+       y1="7.2421875"
+       x2="16.751778"
+       y2="10.1875"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6869"
+       id="linearGradient6875"
+       x1="17.66885"
+       y1="5.3010869"
+       x2="17.66885"
+       y2="22.728249"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6859-2"
+       id="linearGradient6865-2"
+       x1="16.751778"
+       y1="7.2421875"
+       x2="16.751778"
+       y2="10.1875"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient6859-2">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop6861-0" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0;"
+         offset="1"
+         id="stop6863-1" />
+    </linearGradient>
+    <linearGradient
+       y2="10.1875"
+       x2="16.751778"
+       y1="7.2421875"
+       x1="16.751778"
+       gradientUnits="userSpaceOnUse"
+       id="linearGradient6892"
+       xlink:href="#linearGradient6859-2"
+       inkscape:collect="always" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6914"
+       id="linearGradient6920"
+       x1="15.865708"
+       y1="17.835768"
+       x2="15.865708"
+       y2="21"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6924"
+       id="linearGradient6930"
+       x1="15.59375"
+       y1="23.203125"
+       x2="15.59375"
+       y2="26"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient6936"
+       id="linearGradient6942"
+       x1="15.616699"
+       y1="21.594204"
+       x2="15.616699"
+       y2="27.06004"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="translate(0,0.019699)" />
+    <filter
+       inkscape:collect="always"
+       id="filter6962"
+       x="-0.18475209"
+       width="1.3695042"
+       y="-0.31176915"
+       height="1.6235383">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="0.32475953"
+         id="feGaussianBlur6964" />
+    </filter>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="5.6568542"
+     inkscape:cx="20.343696"
+     inkscape:cy="3.7141481"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     inkscape:snap-bbox="true"
+     inkscape:snap-nodes="false"
+     inkscape:window-width="1600"
+     inkscape:window-height="841"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1">
+    <inkscape:grid
+       type="xygrid"
+       id="grid6027" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata6024">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer">
+    <path
+       sodipodi:type="arc"
+       style="opacity:0.3;fill:#000000;fill-opacity:1;stroke:none;filter:url(#filter6962)"
+       id="path6944"
+       sodipodi:cx="15.265625"
+       sodipodi:cy="28.78125"
+       sodipodi:rx="2.109375"
+       sodipodi:ry="1.25"
+       d="m 17.375,28.78125 a 2.109375,1.25 0 1 1 -4.21875,0 2.109375,1.25 0 1 1 4.21875,0 z"
+       transform="matrix(1.2010763,0,0,1.3735147,-2.8351801,-10.281469)" />
+    <path
+       
style="fill:url(#linearGradient6942);fill-opacity:1;stroke:#2e3436;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
+       d="m 14.5,18.519699 2,0 0,9.995926 c 0,0 -0.001,0.984375 -0.984375,0.984375 C 14.532257,29.5 
14.5,28.515625 14.5,28.515625 z"
+       id="rect6867"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="ccczcc" />
+    <rect
+       style="fill:url(#linearGradient6920);fill-opacity:1;stroke:none"
+       id="rect6912"
+       width="2.990447"
+       height="5"
+       x="14.009553"
+       y="17" />
+    <path
+       sodipodi:type="arc"
+       
style="fill:url(#radialGradient6037);fill-opacity:1;stroke:url(#linearGradient6875);stroke-width:1.48626076999999990;stroke-opacity:1"
+       id="path6029"
+       sodipodi:cx="16.789009"
+       sodipodi:cy="15.568204"
+       sodipodi:rx="10.403828"
+       sodipodi:ry="10.403828"
+       d="m 27.192837,15.568204 a 10.403828,10.403828 0 1 1 -20.8076556,0 10.403828,10.403828 0 1 1 
20.8076556,0 z"
+       transform="matrix(0.67282935,0,0,0.67282935,4.2038612,1.0252547)" />
+    <path
+       sodipodi:type="arc"
+       
style="opacity:0.25203253;fill:none;stroke:url(#linearGradient6847);stroke-width:1.71491659;stroke-opacity:1"
+       id="path6029-6"
+       sodipodi:cx="16.789009"
+       sodipodi:cy="15.568204"
+       sodipodi:rx="10.403828"
+       sodipodi:ry="10.403828"
+       d="m 27.192837,15.568204 a 10.403828,10.403828 0 1 1 -20.8076556,0 10.403828,10.403828 0 1 1 
20.8076556,0 z"
+       transform="matrix(0.58311869,0,0,-0.58311869,5.7100144,20.57811)" />
+    <path
+       sodipodi:type="arc"
+       style="opacity:0.62601624;fill:url(#linearGradient6865);fill-opacity:1;stroke:none"
+       id="path6849"
+       sodipodi:cx="16.665859"
+       sodipodi:cy="8.828125"
+       sodipodi:rx="3.6658583"
+       sodipodi:ry="2.265625"
+       d="m 20.331717,8.828125 a 3.6658583,2.265625 0 1 1 -7.331716,0 3.6658583,2.265625 0 1 1 7.331716,0 z"
+       transform="matrix(0.95475594,0,0,1.1034483,-0.41182811,-1.2413798)" />
+  </g>
+</svg>
diff --git a/src/mapView.js b/src/mapView.js
index 916337e..8c26ad3 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -19,7 +19,9 @@
  */
 
 const Clutter = imports.gi.Clutter;
+const Cogl = imports.gi.Cogl;
 const Gdk = imports.gi.Gdk;
+const GdkPixbuf = imports.gi.GdkPixbuf;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const GtkChamplain = imports.gi.GtkChamplain;
@@ -32,6 +34,7 @@ const Mainloop = imports.mainloop;
 const Application = imports.application;
 const Properties = imports.properties;
 const Utils = imports.utils;
+const Path = imports.path;
 const _ = imports.gettext.gettext;
 
 const MapType = {
@@ -129,13 +132,42 @@ const MapView = new Lang.Class({
     },
 
     _showUserLocation: function(location, animate) {
-        if (location.accuracy <= 0)
+        if (location.accuracy == Geocode.LOCATION_ACCURACY_UNKNOWN)
             return;
 
         this._gotoLocation(location, animate);
 
         this._userLocationLayer.remove_all();
 
+        let locationMarker = new Champlain.CustomMarker();
+        try {
+            let pixbuf = GdkPixbuf.Pixbuf.new_from_file(Path.ICONS_DIR + "/pin.svg");
+            let image = new Clutter.Image();
+            image.set_data(pixbuf.get_pixels(),
+                           Cogl.PixelFormat.RGBA_8888,
+                           pixbuf.get_width(),
+                           pixbuf.get_height(),
+                           pixbuf.get_rowstride());
+
+            locationMarker.set_location(location.latitude, location.longitude);
+            locationMarker.set_reactive(false);
+            // FIXME: Using deprecated function here cause I failed to get the same result
+            //        with locationMarker.set_pivot_point(0.5, 0).
+            locationMarker.set_anchor_point_from_gravity(Clutter.Gravity.SOUTH);
+            let actor = new Clutter.Actor();
+            actor.set_content(image);
+            actor.set_size(pixbuf.get_width(), pixbuf.get_height());
+            locationMarker.add_actor(actor);
+        } catch(e) {
+            log("Failed to load image: " + e.message);
+            return;
+        }
+
+        if (location.accuracy == 0) {
+            this._userLocationLayer.add_marker(locationMarker);
+            return;
+        }
+
         // FIXME: Perhaps this is a misuse of Champlain.Point class and we
         // should draw the cirlce ourselves using Champlain.CustomMarker?
         // Although for doing so we'll need to add a C lib as cairo isn't
@@ -167,6 +199,7 @@ const MapView = new Lang.Class({
         let zoom = Utils.getZoomLevelForAccuracy(location.accuracy);
         allocSize(zoom);
         this._userLocationLayer.add_marker(accuracyMarker);
+        this._userLocationLayer.add_marker(locationMarker);
 
         if (this._zoomLevelId > 0)
             this._view.disconnect(this._zoomLevelId);
diff --git a/src/path.js.in b/src/path.js.in
index 5b38c41..56122ee 100644
--- a/src/path.js.in
+++ b/src/path.js.in
@@ -1,4 +1,4 @@
 let LOCALE_DIR = "@localedir@";
 let STYLE_DIR = "@pkgdatadir@/style/";
-let ICONS_DIR = "@pkgdatadir@/icons/";
+let ICONS_DIR = "@pkgdatadir@/pixmaps";
 let RESOURCE_DIR = "@pkgdatadir@";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]