[gnome-maps/wip/mlundblad/night-mode] mapView: Use dark tiles when night mode is active
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/night-mode] mapView: Use dark tiles when night mode is active
- Date: Thu, 4 Jun 2020 22:30:01 +0000 (UTC)
commit 9fe7f9409f114191c5d537b33eea1fdbb1f725f7
Author: Marcus Lundblad <ml update uu se>
Date: Fri Jun 5 00:28:10 2020 +0200
mapView: Use dark tiles when night mode is active
Use the dark tile set, if available from the service
file when night mode is activated.
src/mapView.js | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index fcf4481d..b81924a2 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -42,6 +42,7 @@ const MapWalker = imports.mapWalker;
const Place = imports.place;
const PlaceMarker = imports.placeMarker;
const RouteQuery = imports.routeQuery;
+const Service = imports.service;
const ShapeLayer = imports.shapeLayer;
const StoredRoute = imports.storedRoute;
const TransitArrivalMarker = imports.transitArrivalMarker;
@@ -198,10 +199,28 @@ var MapView = GObject.registerClass({
}
});
+ /* if dark tiles is available, and not using local tiles,
+ * setup handler to switch style
+ */
+ if (Service.getService().tiles.streetDark &&
+ this._mapType !== MapType.LOCAL) {
+ Application.settings.connect('changed::night-mode',
+ this._onNightModeChanged.bind(this));
+ }
+
this._initScale(view);
return view;
}
+ _onNightModeChanged() {
+ if (this._mapType === MapType.STREET) {
+ if (Application.settings.get('night-mode'))
+ this.view.map_source = MapSource.createStreetDarkSource();
+ else
+ this.view.map_source = MapSource.createStreetSource();
+ }
+ }
+
/* create and store a route layer, pass true to get a dashed line */
_createRouteLayer(dashed, lineColor, width) {
let red = Color.parseColor(lineColor, 0);
@@ -323,11 +342,16 @@ var MapView = GObject.registerClass({
this._mapType = mapType;
if (mapType !== MapType.LOCAL) {
- if (mapType === MapType.AERIAL)
+ if (mapType === MapType.AERIAL) {
this.view.map_source = MapSource.createAerialSource();
- else
- this.view.map_source = MapSource.createStreetSource();
-
+ } else {
+ if (Service.getService().tiles.streetDark &&
+ Application.settings.get('night-mode')) {
+ this.view.map_source = MapSource.createStreetDarkSource();
+ } else {
+ this.view.map_source = MapSource.createStreetSource();
+ }
+ }
if (!this._attribution) {
this._attribution = new MapSource.AttributionLogo(this.view);
this.view.add_child(this._attribution);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]