[gnome-maps/wip/mlundblad/additional-place-icons: 3/4] WIP: place: Return place icon based on osmType and osmValue




commit c5f5b6c90cb9805b4e097eb0ad911898aecc7024
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 | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
---
diff --git a/src/place.js b/src/place.js
index 05f8dd09..5045da3a 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,46 @@ 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':
+                switch (this._osmValue) {
+                    case 'bus_stop': return 'route-transit-bus-symbolic';
+                }
+                break;
+            case 'tourism':
+                switch (this._osmValue) {
+                    case 'hotel':
+                    case 'hostel':
+                        return 'bed-symbolic';
+                }
+                break;
+            case 'railway':
+                switch (this._osmValue) {
+                    case 'halt':
+                    case 'station':
+                        return 'route-transit-train-symbolic';
+                    case 'tram_stop':
+                        return 'route-transit-tram-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]