[gnome-maps/wip/mlundblad/additional-place-icons: 1/3] WIP: Add utility module for place icons
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/additional-place-icons: 1/3] WIP: Add utility module for place icons
- Date: Wed, 14 Apr 2021 20:30:41 +0000 (UTC)
commit 7b4a87bfb063f64fe76f1ab237b41523581b661b
Author: Marcus Lundblad <ml update uu se>
Date: Tue Apr 13 23:13:50 2021 +0200
WIP: Add utility module for place icons
Add function for mapping place icon names
to places based on types.
src/org.gnome.Maps.src.gresource.xml | 1 +
src/placeIcons.js | 107 +++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+)
---
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index cec373ea..3c5bc128 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -62,6 +62,7 @@
<file>placeDialog.js</file>
<file>placeEntry.js</file>
<file>placeFormatter.js</file>
+ <file>placeIcons.js</file>
<file>placeListRow.js</file>
<file>placeMarker.js</file>
<file>placePopover.js</file>
diff --git a/src/placeIcons.js b/src/placeIcons.js
new file mode 100644
index 00000000..ddf94638
--- /dev/null
+++ b/src/placeIcons.js
@@ -0,0 +1,107 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2021 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+/**
+ * Mapping OSM key/values to place icons.
+ * Keys in top map correspond to osmKey from Place.
+ * Keys in nested maps correspond to osmValue from Place,
+ * _ matches catch-all case for that osmKey.
+ */
+const TYPE_ICON_MAP = {
+ aeroway: {
+ aerodrome: 'route-transit-airplane-symbolic'
+ },
+ amenity: {
+ bar: 'bar-symbolic',
+ bus_station: 'route-transit-bus-symbolic',
+ cafe: 'cafe-symbolic',
+ charging_station: 'electric-car-symbolic',
+ cinema: 'video-camera-symbolic',
+ clinic: 'hospital-sign-symbolic',
+ doctors: 'hospital-sign-symbolic',
+ fast_food: 'restaurant-symbolic',
+ ferry_terminal: 'route-transit-ferry-symbolic',
+ fuel: 'fuel-symbolic',
+ hospital: 'hospital-symbolic',
+ night_club: 'bar-symbolic',
+ parking: 'parking-sign-symbolic',
+ post_office: 'post-box-symbolic',
+ pub: 'pub-symbolic',
+ restaurant: 'restaurant-symbolic',
+ school: 'school-symbolic',
+ university: 'school-symbolic'
+ },
+ building: {
+ yes: 'building-symbolic',
+ railway_station: 'route-transit-train'
+ },
+ highway: {
+ bus_stop: 'route-transit-bus-symbolic',
+ cycleway: 'route-bike-symbolic',
+ footway: 'route-pedestrian-symbolic',
+ pedestrian: 'route-pedestrian-symbolic',
+ steps: 'route-pedestrian-symbolic',
+ path: 'route-pedestrian-symbolic',
+ _: 'route-car-symbolic'
+ },
+ leisure: {
+ nature_reserve: 'tree-symbolic',
+ park: 'tree-symbolic'
+ },
+ natural: {
+ peak: 'mountain-symbolic'
+ },
+ office: {
+ _: 'building-symbolic'
+ },
+ place: {
+ city: 'city-symbolic',
+ hamlet: 'town-symbolic',
+ suburb: 'town-symbolic',
+ town: 'town-symbolic',
+ village: 'town-symbolic'
+ },
+ railway: {
+ halt: 'route-transit-train-symbolic',
+ station: 'route-transit-train-symbolic',
+ tram_stop: 'route-transit-tram-symbolic'
+ },
+ shop: {
+ _: 'shopping-cart-symbolic'
+ },
+ tourism: {
+ alpine_hut: 'bed-symbolic',
+ attraction: 'photo-camera-symbolic',
+ artwork: 'photo-camera-symbolic',
+ hostel: 'bed-symbolic',
+ hotel: 'bed-symbolic',
+ museum: 'museum-symbolic'
+ }
+};
+
+/**
+ * Get place icon name suitable for a Place.
+ */
+function getIconForPlace(place) {
+ return TYPE_ICON_MAP?.[place.osmKey]?.[place.osmValue] ??
+ TYPE_ICON_MAP?.[place.osmKey]?.['_'] ?? 'map-marker-symbolic';
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]