[gnome-maps/wip/mlundblad/additional-place-icons: 1/2] WIP: place: Return place icon based on osmType and osmValue
- From: Marcus Lundblad <mlundblad src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [gnome-maps/wip/mlundblad/additional-place-icons: 1/2] WIP: place: Return place icon based on osmType and osmValue
 
- Date: Tue,  6 Apr 2021 21:18:59 +0000 (UTC)
 
commit 4444d0eda038bdfd3160d006146fe40c91572c7f
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Apr 6 22:02:03 2021 +0200
    WIP: place: Return place icon based on osmType and osmValue
 src/place.js | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
---
diff --git a/src/place.js b/src/place.js
index 3616c682..227274a8 100644
--- a/src/place.js
+++ b/src/place.js
@@ -22,6 +22,7 @@
 const _ = imports.gettext.gettext;
 
 const Geocode = imports.gi.GeocodeGlib;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 
@@ -249,6 +250,34 @@ class Place extends Geocode.Place {
         this._nativeName = nativeName;
     }
 
+    get icon() {
+        return Gio.Icon.new_for_string(this._getIconName());
+    }
+
+    _getIconName() {
+        // TODO: select icon name based on osmKey/osmValue
+        switch (this._osmKey) {
+            case 'amenity':
+                switch (this._osmValue) {
+                    case 'fuel':       return 'fuel-symbolic';
+                    case 'restaurant': return 'restaurant-symbolic';
+                }
+                break;
+            case 'highway':
+                break;
+            case 'tourism':
+                switch (this._osmValue) {
+                    case 'hotel':
+                    case 'hostel':
+                        return 'bed-symbolic';
+                }
+                break;
+            case 'shop':
+                return 'shopping-cart-symbolic';
+        }
+        return 'map-marker-symbolic';
+    }
+
     toJSON() {
         let bounding_box = null;
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]