diff options
author | Marcus Lundblad <ml@update.uu.se> | 2021-11-29 22:47:27 +0100 |
---|---|---|
committer | Marcus Lundblad <ml@update.uu.se> | 2022-01-06 22:22:33 +0100 |
commit | 9d3fab7f7bc3d2da5a39dcfb55d5ef9d5be6d76e (patch) | |
tree | 4b624c35e377ba1c7b19dfc482e69a753bbb67eb /src | |
parent | f3943a2d915dd199c1c915abf92cbb3fecaf7b08 (diff) | |
download | gnome-maps-9d3fab7f7bc3d2da5a39dcfb55d5ef9d5be6d76e.tar.gz |
Add module for place zoom levels
Add utility module to define default
zoom levels for place types.
Diffstat (limited to 'src')
-rw-r--r-- | src/org.gnome.Maps.src.gresource.xml.in | 1 | ||||
-rw-r--r-- | src/placeZoom.js | 68 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/org.gnome.Maps.src.gresource.xml.in b/src/org.gnome.Maps.src.gresource.xml.in index 2338a132..da8266e7 100644 --- a/src/org.gnome.Maps.src.gresource.xml.in +++ b/src/org.gnome.Maps.src.gresource.xml.in @@ -68,6 +68,7 @@ <file>placeStore.js</file> <file>placeView.js</file> <file>placeViewImage.js</file> + <file>placeZoom.js</file> <file>printLayout.js</file> <file>printOperation.js</file> <file>route.js</file> diff --git a/src/placeZoom.js b/src/placeZoom.js new file mode 100644 index 00000000..389d720e --- /dev/null +++ b/src/placeZoom.js @@ -0,0 +1,68 @@ +/* -*- 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> + */ + +const TYPE_ZOOM_MAP = { + amenity: { + _: 17 + }, + highway: { + bus_stop: 17 + }, + place: { + continent: 4, + ocean: 4, + sea: 5, + country: 6, + state: 7, + region: 8, + province: 8, + county: 8, + municipality: 8, + island: 9, + city: 10, + town: 12, + borough: 12, + village: 15, + suburb: 15, + hamlet: 15, + islet: 16, + _: 17 + + }, + railway: { + halt: 16, + station: 14, + tram_stop: 16 + }, + shop: { + _: 17 + } +} + +/** + * Get default zoom level for a given place, if one is defined + * otherwise return undefined, in which case the maximum zoom level + * (as defined by the map source) could be used. + */ +function getZoomLevelForPlace(place) { + return TYPE_ZOOM_MAP?.[place.osmKey]?.[place.osmValue] ?? + TYPE_ZOOM_MAP?.[place.osmKey]?.['_']; +} |