diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-01 23:42:35 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-01 23:42:35 -0700 |
commit | d04cd5a9ca34f0528f3db6361641d20bc1a13320 (patch) | |
tree | db99b29c7ac16f4d74635450afb6be9cae264d90 /modern/src | |
parent | 665daf83ceade22def940066905e366d9529b60b (diff) | |
download | trackermap-web-d04cd5a9ca34f0528f3db6361641d20bc1a13320.tar.gz trackermap-web-d04cd5a9ca34f0528f3db6361641d20bc1a13320.tar.bz2 trackermap-web-d04cd5a9ca34f0528f3db6361641d20bc1a13320.zip |
Add raster map layer
Diffstat (limited to 'modern/src')
-rw-r--r-- | modern/src/MainMap.js | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js index aea6dd89..fdc193c2 100644 --- a/modern/src/MainMap.js +++ b/modern/src/MainMap.js @@ -37,11 +37,43 @@ const mapStateToProps = state => ({ class MainMap extends Component { componentDidMount() { - const map = new mapboxgl.Map({ + /*const map = new mapboxgl.Map({ container: this.mapContainer, style: 'https://cdn.traccar.com/map/basic.json', center: [0, 0], zoom: 1 + });*/ + + const map = new mapboxgl.Map({ + container: this.mapContainer, + style: { + 'version': 8, + 'sources': { + 'raster-tiles': { + 'type': 'raster', + 'tiles': [ + 'https://a.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png', + 'https://b.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png', + 'https://c.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png', + 'https://d.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png' + ], + 'tileSize': 256, + 'attribution': '© <a target="_top" rel="noopener" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a target="_top" rel="noopener" href="https://carto.com/attribution">CARTO</a>' + } + }, + 'glyphs': 'https://cdn.traccar.com/map/fonts/{fontstack}/{range}.pbf', + 'layers': [ + { + 'id': 'simple-tiles', + 'type': 'raster', + 'source': 'raster-tiles', + 'minzoom': 0, + 'maxzoom': 22 + } + ] + }, + center: [0, 0], + zoom: 1 }); map.on('load', () => this.mapDidLoad(map)); |