Initial work to convert from Mapbox GL v1.13 to MapLibre v2.4.0.

This commit is contained in:
Luke Seelenbinder
2022-10-27 14:02:47 +02:00
parent 7d5fb23130
commit 74cacd5bdf
41 changed files with 32695 additions and 6879 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import style from './style.js'
import {format} from '@mapbox/mapbox-gl-style-spec'
import {format} from '@maplibre/maplibre-gl-style-spec'
import ReconnectingWebSocket from 'reconnecting-websocket'
export class ApiStyleStore {
+1 -1
View File
@@ -1,4 +1,4 @@
import {diff} from '@mapbox/mapbox-gl-style-spec'
import {diff} from '@maplibre/maplibre-gl-style-spec'
export function diffMessages(beforeStyle, afterStyle) {
const changes = diff(beforeStyle, afterStyle)
+1 -1
View File
@@ -1,4 +1,4 @@
import {latest} from '@mapbox/mapbox-gl-style-spec'
import {latest} from '@maplibre/maplibre-gl-style-spec'
export const combiningFilterOps = ['all', 'any', 'none']
export const setFilterOps = ['in', '!in']
export const otherFilterOps = Object
+1 -1
View File
@@ -1,4 +1,4 @@
import {latest} from '@mapbox/mapbox-gl-style-spec'
import {latest} from '@maplibre/maplibre-gl-style-spec'
export function changeType(layer, newType) {
const changedPaintProps = { ...layer.paint }
+2 -2
View File
@@ -1,4 +1,4 @@
import MapboxGl from 'mapbox-gl'
import MapLibreGl from "maplibre-gl"
import {readFileSync} from 'fs'
const data = readFileSync(__dirname+"/../../node_modules/@mapbox/mapbox-gl-rtl-text/mapbox-gl-rtl-text.js", "utf8");
@@ -8,4 +8,4 @@ const blob = new window.Blob([data], {
});
const objectUrl = window.URL.createObjectURL(blob);
MapboxGl.setRTLTextPlugin(objectUrl);
MapLibreGl.setRTLTextPlugin(objectUrl, () => {});
+1 -6
View File
@@ -1,11 +1,6 @@
function asBool(queryObj, key) {
if(queryObj.hasOwnProperty(key)) {
if(queryObj[key].match(/^false|0$/)) {
return false;
}
else {
return true;
}
return !queryObj[key].match(/^false|0$/);
}
else {
return false;
+2 -2
View File
@@ -1,6 +1,6 @@
export default function(a, b) {
a = parseFloat(a, 10);
b = parseFloat(b, 10);
a = parseFloat(a);
b = parseFloat(b);
if(a < b) {
return -1
+2 -4
View File
@@ -1,11 +1,10 @@
export function deleteSource(mapStyle, sourceId) {
const remainingSources = { ...mapStyle.sources}
delete remainingSources[sourceId]
const changedStyle = {
return {
...mapStyle,
sources: remainingSources
}
return changedStyle
}
@@ -18,10 +17,9 @@ export function changeSource(mapStyle, sourceId, source) {
...mapStyle.sources,
[sourceId]: source
}
const changedStyle = {
return {
...mapStyle,
sources: changedSources
}
return changedStyle
}
+4 -6
View File
@@ -1,4 +1,4 @@
import deref from '@mapbox/mapbox-gl-style-spec/deref'
import {derefLayers} from '@maplibre/maplibre-gl-style-spec'
import tokens from '../config/tokens.json'
// Empty style is always used if no style could be restored or fetched
@@ -25,19 +25,17 @@ function ensureHasNoInteractive(style) {
return changedLayer
})
const nonInteractiveStyle = {
return {
...style,
layers: changedLayers
}
return nonInteractiveStyle
}
function ensureHasNoRefs(style) {
const derefedStyle = {
return {
...style,
layers: deref(style.layers)
layers: derefLayers(style.layers)
}
return derefedStyle
}
function ensureStyleValidity(style) {
+1 -1
View File
@@ -30,7 +30,7 @@ function loadStoredStyles() {
function isStyleKey(key) {
const parts = key.split(":")
return parts.length == 3 && parts[0] === storagePrefix && parts[1] === stylePrefix
return parts.length === 3 && parts[0] === storagePrefix && parts[1] === stylePrefix
}
// Load style id from key