aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-07-04 10:34:53 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-07-04 10:34:53 -0700
commitd187ed9b1ffa1835c5498ff5f2e3652447d7c68c (patch)
tree9980db1c83d4c659151915879ca85c47eb3db6df
parentf2c65d56b20998384c1539b5d1c62c0605a0b8f8 (diff)
downloadetbsa-traccar-web-d187ed9b1ffa1835c5498ff5f2e3652447d7c68c.tar.gz
etbsa-traccar-web-d187ed9b1ffa1835c5498ff5f2e3652447d7c68c.tar.bz2
etbsa-traccar-web-d187ed9b1ffa1835c5498ff5f2e3652447d7c68c.zip
Migrate to MapLibre
-rw-r--r--modern/README.md2
-rw-r--r--modern/package.json2
-rw-r--r--modern/public/styles.css2
-rw-r--r--modern/src/map/CurrentLocationMap.js4
-rw-r--r--modern/src/map/Map.js10
-rw-r--r--modern/src/map/PositionsMap.js6
-rw-r--r--modern/src/map/ReplayPathMap.js4
-rw-r--r--modern/src/map/switcher/switcher.css12
-rw-r--r--modern/src/map/switcher/switcher.js10
9 files changed, 26 insertions, 26 deletions
diff --git a/modern/README.md b/modern/README.md
index b5cb212..866dfd3 100644
--- a/modern/README.md
+++ b/modern/README.md
@@ -1,6 +1,6 @@
This is a new version of the Traccar web app. It is still in a very early stage of development.
-It uses [React](https://reactjs.org/), [Material UI](https://material-ui.com/) and [Mapbox GL JS](https://docs.mapbox.com/mapbox-gl-js/api/). Feedback and contributions are welcome.
+It uses [React](https://reactjs.org/), [Material UI](https://material-ui.com/) and [MapLibre GL JS](https://maplibre.org/). Feedback and contributions are welcome.
To run the project in development mode:
diff --git a/modern/package.json b/modern/package.json
index a18d656..0658ec3 100644
--- a/modern/package.json
+++ b/modern/package.json
@@ -12,7 +12,7 @@
"@reduxjs/toolkit": "^1.6.0",
"@turf/turf": "^6.4.0",
"canvas-tint-image": "^2.0.1",
- "mapbox-gl": "^1.12.0",
+ "maplibre-gl": "^1.15.0",
"moment": "^2.29.1",
"react": "^16.13.1",
"react-container-dimensions": "^1.4.1",
diff --git a/modern/public/styles.css b/modern/public/styles.css
index 60d1208..7e9de65 100644
--- a/modern/public/styles.css
+++ b/modern/public/styles.css
@@ -3,6 +3,6 @@ canvas {
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}
-.mapboxgl-popup-content {
+.maplibregl-popup-content {
padding: 10px !important;
}
diff --git a/modern/src/map/CurrentLocationMap.js b/modern/src/map/CurrentLocationMap.js
index 31e6e28..06aaad0 100644
--- a/modern/src/map/CurrentLocationMap.js
+++ b/modern/src/map/CurrentLocationMap.js
@@ -1,10 +1,10 @@
-import mapboxgl from 'mapbox-gl';
+import maplibregl from 'maplibre-gl';
import { useEffect } from 'react';
import { map } from './Map';
const CurrentLocationMap = () => {
useEffect(() => {
- const control = new mapboxgl.GeolocateControl({
+ const control = new maplibregl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true,
timeout: 5000,
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js
index a973cf7..46c59d2 100644
--- a/modern/src/map/Map.js
+++ b/modern/src/map/Map.js
@@ -1,6 +1,6 @@
-import 'mapbox-gl/dist/mapbox-gl.css';
+import 'maplibre-gl/dist/maplibre-gl.css';
import './switcher/switcher.css';
-import mapboxgl from 'mapbox-gl';
+import maplibregl from 'maplibre-gl';
import { SwitcherControl } from './switcher/switcher';
import React, { useRef, useLayoutEffect, useEffect, useState } from 'react';
import { deviceCategories } from '../common/deviceCategories';
@@ -14,7 +14,7 @@ const element = document.createElement('div');
element.style.width = '100%';
element.style.height = '100%';
-export const map = new mapboxgl.Map({
+export const map = new maplibregl.Map({
container: element,
style: styleOsm(),
});
@@ -55,7 +55,7 @@ const initMap = async () => {
map.on('load', initMap);
-map.addControl(new mapboxgl.NavigationControl({
+map.addControl(new maplibregl.NavigationControl({
showCompass: false,
}));
@@ -89,7 +89,7 @@ const Map = ({ children }) => {
const mapboxAccessToken = useAttributePreference('mapboxAccessToken');
useEffect(() => {
- mapboxgl.accessToken = mapboxAccessToken;
+ maplibregl.accessToken = mapboxAccessToken;
}, [mapboxAccessToken]);
useEffect(() => {
diff --git a/modern/src/map/PositionsMap.js b/modern/src/map/PositionsMap.js
index baa801f..35d6d92 100644
--- a/modern/src/map/PositionsMap.js
+++ b/modern/src/map/PositionsMap.js
@@ -1,6 +1,6 @@
import React, { useCallback, useEffect } from 'react';
import ReactDOM from 'react-dom';
-import mapboxgl from 'mapbox-gl';
+import maplibregl from 'maplibre-gl';
import { Provider, useSelector } from 'react-redux';
import { map } from './Map';
@@ -54,7 +54,7 @@ const PositionsMap = ({ positions }) => {
placeholder
);
- new mapboxgl.Popup({
+ new maplibregl.Popup({
offset: 25,
anchor: 'top'
})
@@ -129,7 +129,7 @@ const PositionsMap = ({ positions }) => {
map.on('click', clusters, onClusterClick);
return () => {
- Array.from(map.getContainer().getElementsByClassName('mapboxgl-popup')).forEach(el => el.remove());
+ Array.from(map.getContainer().getElementsByClassName('maplibregl-popup')).forEach(el => el.remove());
map.off('mouseenter', id, onMouseEnter);
map.off('mouseleave', id, onMouseLeave);
diff --git a/modern/src/map/ReplayPathMap.js b/modern/src/map/ReplayPathMap.js
index feab071..b40aa69 100644
--- a/modern/src/map/ReplayPathMap.js
+++ b/modern/src/map/ReplayPathMap.js
@@ -1,4 +1,4 @@
-import mapboxgl from 'mapbox-gl';
+import maplibregl from 'maplibre-gl';
import { useEffect } from 'react';
import { map } from './Map';
@@ -46,7 +46,7 @@ const ReplayPathMap = ({ positions }) => {
},
});
if (coordinates.length) {
- const bounds = coordinates.reduce((bounds, item) => bounds.extend(item), new mapboxgl.LngLatBounds(coordinates[0], coordinates[0]));
+ const bounds = coordinates.reduce((bounds, item) => bounds.extend(item), new maplibregl.LngLatBounds(coordinates[0], coordinates[0]));
map.fitBounds(bounds, {
padding: { top: 50, bottom: 250, left: 25, right: 25 },
});
diff --git a/modern/src/map/switcher/switcher.css b/modern/src/map/switcher/switcher.css
index 6c8fdb4..e3d491c 100644
--- a/modern/src/map/switcher/switcher.css
+++ b/modern/src/map/switcher/switcher.css
@@ -1,9 +1,9 @@
-.mapboxgl-style-list
+.maplibregl-style-list
{
display: none;
}
-.mapboxgl-ctrl-group .mapboxgl-style-list button
+.maplibregl-ctrl-group .maplibregl-style-list button
{
background: none;
border: none;
@@ -16,22 +16,22 @@
height: auto;
}
-.mapboxgl-style-list button.active
+.maplibregl-style-list button.active
{
font-weight: bold;
}
-.mapboxgl-style-list button:hover
+.maplibregl-style-list button:hover
{
background-color: rgba(0, 0, 0, 0.05);
}
-.mapboxgl-style-list button + button
+.maplibregl-style-list button + button
{
border-top: 1px solid #ddd;
}
-.mapboxgl-style-switcher
+.maplibregl-style-switcher
{
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iNTQuODQ5cHgiIGhlaWdodD0iNTQuODQ5cHgiIHZpZXdCb3g9IjAgMCA1NC44NDkgNTQuODQ5IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1NC44NDkgNTQuODQ5OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PGc+PGc+PGc+PHBhdGggZD0iTTU0LjQ5NywzOS42MTRsLTEwLjM2My00LjQ5bC0xNC45MTcsNS45NjhjLTAuNTM3LDAuMjE0LTEuMTY1LDAuMzE5LT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xnPjwvZz48Zz48L2c+PGc+PC9nPjxnPjwvZz48Zz48L2c+PGc+PC9nPjxnPjwvZz48Zz48L2c+PGc+PC9nPjwvc3ZnPg==);
background-position: center;
diff --git a/modern/src/map/switcher/switcher.js b/modern/src/map/switcher/switcher.js
index ff9fbe9..a755645 100644
--- a/modern/src/map/switcher/switcher.js
+++ b/modern/src/map/switcher/switcher.js
@@ -15,12 +15,12 @@ export class SwitcherControl {
onAdd(map) {
this.map = map;
this.controlContainer = document.createElement('div');
- this.controlContainer.classList.add('mapboxgl-ctrl');
- this.controlContainer.classList.add('mapboxgl-ctrl-group');
+ this.controlContainer.classList.add('maplibregl-ctrl');
+ this.controlContainer.classList.add('maplibregl-ctrl-group');
this.mapStyleContainer = document.createElement('div');
this.styleButton = document.createElement('button');
this.styleButton.type = 'button';
- this.mapStyleContainer.classList.add('mapboxgl-style-list');
+ this.mapStyleContainer.classList.add('maplibregl-style-list');
for (const style of this.styles) {
const styleElement = document.createElement('button');
styleElement.type = 'button';
@@ -48,8 +48,8 @@ export class SwitcherControl {
}
this.mapStyleContainer.appendChild(styleElement);
}
- this.styleButton.classList.add('mapboxgl-ctrl-icon');
- this.styleButton.classList.add('mapboxgl-style-switcher');
+ this.styleButton.classList.add('maplibregl-ctrl-icon');
+ this.styleButton.classList.add('maplibregl-style-switcher');
this.styleButton.addEventListener('click', () => {
this.styleButton.style.display = 'none';
this.mapStyleContainer.style.display = 'block';