Skip to content

Commit 4f7fc01

Browse files
committed
fix(map): add osm1
1 parent 0dd316b commit 4f7fc01

File tree

4 files changed

+59
-10
lines changed

4 files changed

+59
-10
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Map Tiles
3+
sidebar_position: 12
4+
version: 1
5+
---
6+
7+
# Map tiles
8+
9+
Superset uses OSM and Mapbox tiles by default. OSM is free but you you need to set your API MAPBOX TOKEN in config.py
10+
11+
# Default values are equivalent to
12+
```python
13+
DECKGL_BASE_MAP = [
14+
['https://tile.openstreetmap.org/{z}/{x}/{y}.png', 'Streets (OSM)'],
15+
['https://tile.osm.ch/osm-swiss-style/{z}/{x}/{y}.png', 'Topography (OSM)'],
16+
['mapbox://styles/mapbox/streets-v9', 'Streets'],
17+
['mapbox://styles/mapbox/dark-v9', 'Dark'],
18+
['mapbox://styles/mapbox/light-v9', 'Light'],
19+
['mapbox://styles/mapbox/satellite-streets-v9', 'Satellite Streets'],
20+
['mapbox://styles/mapbox/satellite-v9', 'Satellite'],
21+
['mapbox://styles/mapbox/outdoors-v9', 'Outdoors'],
22+
]
23+
```
24+
# For adding your own map tiles, you can use the following format:
25+
- tile:// + your_personal_url or openstreetmap_url
26+
27+
```python
28+
DECKGL_BASE_MAP = [
29+
['tile://https://c.tile.openstreetmap.org/{z}/{x}/{y}.png', 'OpenStreetMap']
30+
]
31+
```
32+
# Enable CORS and set map url in origins option.
33+
34+
# Add also map url in connect-src of TALISMAN_CONFIG variable.

superset-frontend/packages/superset-ui-core/src/validator/validateMapboxStylesUrl.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export default function validateMapboxStylesUrl(v: unknown) {
2929
typeof v === 'string' &&
3030
v.trim().length > 0 &&
3131
(v.trim().startsWith('mapbox://styles/') ||
32-
v.trim().startsWith('tile://http'))
32+
v.trim().startsWith('tile://http') ||
33+
v.trim().includes('osm') ||
34+
v.trim().includes('openstreetmap'))
3335
) {
3436
return false;
3537
}

superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ import { columnChoices, PRIMARY_COLOR } from './controls';
3232
let deckglTiles;
3333

3434
export const DEFAULT_DECKGL_TILES = [
35-
['mapbox://styles/mapbox/streets-v9', 'Streets'],
36-
['mapbox://styles/mapbox/dark-v9', 'Dark'],
37-
['mapbox://styles/mapbox/light-v9', 'Light'],
38-
['mapbox://styles/mapbox/satellite-streets-v9', 'Satellite Streets'],
39-
['mapbox://styles/mapbox/satellite-v9', 'Satellite'],
40-
['mapbox://styles/mapbox/outdoors-v9', 'Outdoors'],
35+
['https://tile.openstreetmap.org/{z}/{x}/{y}.png', 'Streets (OSM)'],
36+
['https://tile.osm.ch/osm-swiss-style/{z}/{x}/{y}.png', 'Topography (OSM)'],
37+
['mapbox://styles/mapbox/streets-v9', 'Streets (Mapbox)'],
38+
['mapbox://styles/mapbox/dark-v9', 'Dark (Mapbox)'],
39+
['mapbox://styles/mapbox/light-v9', 'Light (Mapbox)'],
40+
['mapbox://styles/mapbox/satellite-streets-v9', 'Satellite Streets (Mapbox)'],
41+
['mapbox://styles/mapbox/satellite-v9', 'Satellite (Mapbox)'],
42+
['mapbox://styles/mapbox/outdoors-v9', 'Outdoors (Mapbox)'],
4143
];
4244

4345
const getDeckGLTiles = () => {

superset/config.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ class D3Format(TypedDict, total=False):
421421
# Override the default mapbox tiles
422422
# Default values are equivalent to
423423
# DECKGL_BASE_MAP = [
424+
# ['https://tile.openstreetmap.org/{z}/{x}/{y}.png', 'Streets (OSM)'],
425+
# ['https://tile.osm.ch/osm-swiss-style/{z}/{x}/{y}.png', 'Topography (OSM)'],
424426
# ['mapbox://styles/mapbox/streets-v9', 'Streets'],
425427
# ['mapbox://styles/mapbox/dark-v9', 'Dark'],
426428
# ['mapbox://styles/mapbox/light-v9', 'Light'],
@@ -842,9 +844,14 @@ class D3TimeFormat(TypedDict, total=False):
842844

843845
# CORS Options
844846
# NOTE: enabling this requires installing the cors-related python dependencies
845-
# `pip install .[cors]` or `pip install apache-superset[cors]`, depending
846-
ENABLE_CORS = False
847-
CORS_OPTIONS: dict[Any, Any] = {}
847+
# `pip install .[cors]` or `pip install apache_superset[cors]`, depending
848+
ENABLE_CORS = True
849+
CORS_OPTIONS: dict[Any, Any] = {
850+
"origins": [
851+
"https://tile.openstreetmap.org",
852+
"https://tile.osm.ch",
853+
]
854+
}
848855

849856
# Sanitizes the HTML content used in markdowns to allow its rendering in a safe manner.
850857
# Disabling this option is not recommended for security reasons. If you wish to allow
@@ -1671,6 +1678,8 @@ def EMAIL_HEADER_MUTATOR( # pylint: disable=invalid-name,unused-argument # noq
16711678
"'self'",
16721679
"https://api.mapbox.com",
16731680
"https://events.mapbox.com",
1681+
"https://tile.openstreetmap.org",
1682+
"https://tile.osm.ch",
16741683
],
16751684
"object-src": "'none'",
16761685
"style-src": [
@@ -1702,6 +1711,8 @@ def EMAIL_HEADER_MUTATOR( # pylint: disable=invalid-name,unused-argument # noq
17021711
"'self'",
17031712
"https://api.mapbox.com",
17041713
"https://events.mapbox.com",
1714+
"https://tile.openstreetmap.org",
1715+
"https://tile.osm.ch",
17051716
],
17061717
"object-src": "'none'",
17071718
"style-src": [

0 commit comments

Comments
 (0)