Skip to content

Commit

Permalink
Remove offline url map layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylchauf committed Nov 5, 2021
1 parent aaf1be8 commit 7b1d2e8
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 8 deletions.
1 change: 0 additions & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ In json files, you can just override the primary keys you need. You have to over
- You can also update the map layers. There are two map layers available:

- `mapClassicLayerUrl` for the map version
- `mapClassicLayerUrlOffline` for the map version in offline mode (if not defined `mapClassicLayerUrl` will be used in offline mode)
- `mapSatelliteLayerUrl` for the satellite version. It is optional, so if you want to have only one available map background, you can add `mapSatelliteLayerUrl: undefined`. This will remove the button which allows the user to switch between two map backgrounds.

- `zoomAvailableOffline` allows you to define the zoom modes allowed in offline mode. This allows you to control the amount of disk space required when caching. Default `[13,14,15]`
Expand Down
1 change: 0 additions & 1 deletion frontend/config/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"searchMapZoom": 10,
"mapCredits": "OpenTopoMap",
"mapClassicLayerUrl": "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",
"mapClassicLayerUrlOffline": "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",
"mapSatelliteLayerUrl": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
"zoomAvailableOffline": [13, 14, 15]
}
1 change: 0 additions & 1 deletion frontend/src/components/Map/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export interface MapConfig {
searchMapZoom: number;
mapCredits: string;
mapClassicLayerUrl: string;
mapClassicLayerUrlOffline?: string;
mapSatelliteLayerUrl?: string;
zoomAvailableOffline?: number[];
}
6 changes: 1 addition & 5 deletions frontend/src/services/offline/injectOfflineMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ const LeafletOffline = require('leaflet.offline');
const injectOfflineMode = (map: Map, id: number, center: LatLngBoundsExpression) => {
const mapConfig = getMapConfig();

let mapTilesUrl;
if (navigator.onLine) mapTilesUrl = mapConfig.mapClassicLayerUrl;
else mapTilesUrl = mapConfig.mapClassicLayerUrlOffline ?? mapConfig.mapClassicLayerUrl;

const tileLayerOffline = L.tileLayer
// @ts-ignore no type available in this plugin
.offline(`${mapTilesUrl}?${id}`, {
.offline(`${mapConfig.mapClassicLayerUrl}?${id}`, {
attribution: 'Map data {attribution.OpenStreetMap}',
subdomains: 'abc',
minZoom: Math.min(...(mapConfig?.zoomAvailableOffline ?? [])),
Expand Down

0 comments on commit 7b1d2e8

Please sign in to comment.