Skip to content

Commit 7b46818

Browse files
authored
Replace Mapbox with Maplibre (#469)
1 parent 2d3eefe commit 7b46818

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

app/components/leaflet.directive.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@
9595
map.removeLayer(mapLayers['mouseOver']);
9696
});
9797

98-
var gl = L.mapboxGL({
99-
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
100-
accessToken: '@@OPENSENSEMAP_ACCESS_TOKEN',
101-
style: '@@OPENSENSEMAP_STYLE_URL'
98+
const key = '@@OPENSENSEMAP_ACCESS_TOKEN';
99+
const styleUrl = '@@OPENSENSEMAP_STYLE_URL'
100+
const gl = L.maplibreGL({
101+
attribution: "\u003ca href=\"https://www.maptiler.com/copyright/\" target=\"_blank\"\u003e\u0026copy; MapTiler\u003c/a\u003e \u003ca href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\"\u003e\u0026copy; OpenStreetMap contributors\u003c/a\u003e",
102+
style: styleUrl + "?key=" + key
102103
}).addTo(map);
103-
var mapboxMap = gl.getMapboxMap();
104+
var maplibreMap = gl.getMaplibreMap();
104105

105-
mapboxMap.on('load', layerLoaded);
106+
maplibreMap.on('load', layerLoaded);
106107

107108
L.control.scale().addTo(map);
108109

@@ -152,7 +153,7 @@
152153
function layerLoaded () {
153154
$rootScope.$broadcast('layerloaded', {});
154155
$rootScope.$apply();
155-
mapboxMap.off('load', layerLoaded);
156+
maplibreMap.off('load', layerLoaded);
156157
for (var layerName in mapLayers) {
157158
mapLayers[layerName].on('add', function () {
158159
osemMapData.setLayer(layerName, mapLayers[layerName]);

app/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<link rel="stylesheet" href="bower_components/bootstrap-css-only/css/bootstrap.css" />
3838
<link rel="stylesheet" href="bower_components/Leaflet.awesome-markers/dist/leaflet.awesome-markers.css" />
3939
<link rel="stylesheet" href="bower_components/leaflet.markercluster/dist/MarkerCluster.css" />
40-
<link rel="stylesheet" href="bower_components/mapbox-gl-css/index.css" />
40+
<link rel="stylesheet" href="bower_components/maplibre-gl-css/index.css" />
4141
<link rel="stylesheet" href="bower_components/ngprogress/ngProgress.css" />
4242
<!-- endbower -->
4343
<!-- endbuild -->
@@ -368,8 +368,8 @@
368368
<script src="bower_components/angular-wizard/dist/angular-wizard.min.js"></script>
369369
<script src="bower_components/Leaflet.awesome-markers/dist/leaflet.awesome-markers.js"></script>
370370
<script src="bower_components/leaflet.markercluster/dist/leaflet.markercluster-src.js"></script>
371-
<script src="bower_components/mapbox-gl-js/index.js"></script>
372-
<script src="bower_components/mapbox-gl-leaflet/leaflet-mapbox-gl.js"></script>
371+
<script src="bower_components/maplibre-gl-js/index.js"></script>
372+
<script src="bower_components/maplibre-gl-leaflet/index.js"></script>
373373
<script src="bower_components/d3/d3.js"></script>
374374
<script src="bower_components/Leaflet.FeatureGroup.SubGroup/src/subgroup.js"></script>
375375
<script src="bower_components/angular-ismobile/dist/angular-ismobile.js"></script>

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"leaflet": "1.7.1",
2323
"Leaflet.awesome-markers": "leaflet-awesome-markers#^2.0.2",
2424
"leaflet.markercluster": "1.4.1",
25-
"mapbox-gl-js": "https://api.mapbox.com/mapbox-gl-js/v1.13.1/mapbox-gl.js",
26-
"mapbox-gl-css": "https://api.mapbox.com/mapbox-gl-js/v1.13.1/mapbox-gl.css",
27-
"mapbox-gl-leaflet": "https://github.com/mapbox/mapbox-gl-leaflet.git#f3901fc",
25+
"maplibre-gl-js": "https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.js",
26+
"maplibre-gl-css": "https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.css",
27+
"maplibre-gl-leaflet": "https://unpkg.com/@maplibre/maplibre-gl-leaflet@0.0.17/leaflet-maplibre-gl.js",
2828
"d3": "^4.10.0",
2929
"Leaflet.FeatureGroup.SubGroup": "^1.0.3",
3030
"angular-ismobile": "^1.1.0",

0 commit comments

Comments
 (0)