Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

814/remove mapbox references #816

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[github-action-ci]: https://github.com/maputnik/editor/actions?query=workflow%3Aci
[license]: https://tldrlegal.com/license/mit-license

A free and open visual editor for the [Mapbox GL styles](https://www.mapbox.com/mapbox-gl-style-spec/)
A free and open visual editor for the [MapLibre GL styles](https://maplibre.org/maplibre-style-spec/)
targeted at developers and map designers.


Expand Down Expand Up @@ -36,7 +36,7 @@ The documentation can be found in the [Wiki](https://github.com/maputnik/editor/

## Develop

Maputnik is written in ES6 and is using [React](https://github.com/facebook/react) and [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/api/).
Maputnik is written in ES6 and is using [React](https://github.com/facebook/react) and [MapLibre GL JS](https://maplibre.org/projects/maplibre-gl-js/).

We ensure building and developing Maputnik works with the [current active LTS Node.js version and above](https://github.com/nodejs/Release#release-schedule).

Expand Down
3 changes: 0 additions & 3 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ module.exports = {
extensions: ['.js', '.jsx']
},
module: {
noParse: [
/mapbox-gl\/dist\/mapbox-gl.js/
],
rules: rules
},
node: {
Expand Down
3 changes: 0 additions & 3 deletions config/webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ module.exports = {
extensions: ['.js', '.jsx']
},
module: {
noParse: [
/mapbox-gl\/dist\/mapbox-gl.js/
],
rules: rules
},
node: {
Expand Down
26 changes: 13 additions & 13 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {arrayMoveMutable} from 'array-move'
import url from 'url'
import hash from "string-hash";

import MapMapboxGl from './MapMapboxGl'
import MapMaplibreGl from './MapMaplibreGl'
import MapOpenLayers from './MapOpenLayers'
import LayerList from './LayerList'
import LayerEditor from './LayerEditor'
Expand Down Expand Up @@ -136,7 +136,7 @@ export default class App extends React.Component {
{
key: "m",
handler: () => {
document.querySelector(".mapboxgl-canvas").focus();
document.querySelector(".maplibregl-canvas").focus();
}
},
{
Expand Down Expand Up @@ -220,7 +220,7 @@ export default class App extends React.Component {
survey: false,
debug: false,
},
mapboxGlDebugOptions: {
maplibreGlDebugOptions: {
showTileBoundaries: false,
showCollisionBoxes: false,
showOverdrawInspector: false,
Expand Down Expand Up @@ -290,7 +290,7 @@ export default class App extends React.Component {
// If we're changing renderer reset the map state.
if (
property === 'maputnik:renderer' &&
value !== get(this.state.mapStyle, ['metadata', 'maputnik:renderer'], 'mbgljs')
value !== get(this.state.mapStyle, ['metadata', 'maputnik:renderer'], 'mlgljs')
) {
this.setState({
mapState: 'map'
Expand Down Expand Up @@ -547,7 +547,7 @@ export default class App extends React.Component {
...styleObj,
metadata: {
...styleObj.metadata,
'maputnik:renderer': 'mbgljs'
'maputnik:renderer': 'mlgljs'
}
}
return changedStyle
Expand Down Expand Up @@ -626,7 +626,7 @@ export default class App extends React.Component {

_getRenderer () {
const metadata = this.state.mapStyle.metadata || {};
return metadata['maputnik:renderer'] || 'mbgljs';
return metadata['maputnik:renderer'] || 'mlgljs';
}

onMapChange = (mapView) => {
Expand Down Expand Up @@ -665,9 +665,9 @@ export default class App extends React.Component {
onLayerSelect={this.onLayerSelect}
/>
} else {
mapElement = <MapMapboxGl {...mapProps}
mapElement = <MapMaplibreGl {...mapProps}
onChange={this.onMapChange}
options={this.state.mapboxGlDebugOptions}
options={this.state.maplibreGlDebugOptions}
inspectModeEnabled={this.state.mapState === "inspect"}
highlightedLayer={this.state.mapStyle.layers[this.state.selectedLayerIndex]}
onLayerSelect={this.onLayerSelect} />
Expand Down Expand Up @@ -800,10 +800,10 @@ export default class App extends React.Component {
});
}

onChangeMaboxGlDebug = (key, value) => {
onChangeMaplibreGlDebug = (key, value) => {
this.setState({
mapboxGlDebugOptions: {
...this.state.mapboxGlDebugOptions,
maplibreGlDebugOptions: {
...this.state.maplibreGlDebugOptions,
[key]: value,
}
});
Expand Down Expand Up @@ -870,9 +870,9 @@ export default class App extends React.Component {
const modals = <div>
<ModalDebug
renderer={this._getRenderer()}
mapboxGlDebugOptions={this.state.mapboxGlDebugOptions}
maplibreGlDebugOptions={this.state.maplibreGlDebugOptions}
openlayersDebugOptions={this.state.openlayersDebugOptions}
onChangeMaboxGlDebug={this.onChangeMaboxGlDebug}
onChangeMaplibreGlDebug={this.onChangeMaplibreGlDebug}
onChangeOpenlayersDebug={this.onChangeOpenlayersDebug}
isOpen={this.state.isOpen.debug}
onOpenToggle={this.toggleModal.bind(this, 'debug')}
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default class AppToolbar extends React.Component {

onSkip = (target) => {
if (target === "map") {
document.querySelector(".mapboxgl-canvas").focus();
document.querySelector(".maplibregl-canvas").focus();
}
else {
const el = document.querySelector("#skip-target-"+target);
Expand All @@ -152,7 +152,7 @@ export default class AppToolbar extends React.Component {
id: "inspect",
group: "general",
title: "Inspect",
disabled: this.props.renderer !== 'mbgljs',
disabled: this.props.renderer !== 'mlgljs',
},
{
id: "filter-deuteranopia",
Expand Down
2 changes: 1 addition & 1 deletion src/components/FilterEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function createStyleFromFilter (filter) {
"id": "tmp",
"version": 8,
"name": "Empty Style",
"metadata": {"maputnik:renderer": "mbgljs"},
"metadata": {"maputnik:renderer": "mlgljs"},
"sources": {
"tmp": {
"type": "geojson",
Expand Down
2 changes: 1 addition & 1 deletion src/components/InputSpec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function optionsLabelLength(options) {
return sum
}

/** Display any field from the Mapbox GL style spec and
/** Display any field from the Maplibre GL style spec and
* choose the correct field component based on the @{fieldSpec}
* to display @{value}. */
export default class SpecField extends React.Component {
Expand Down
21 changes: 10 additions & 11 deletions src/components/MapMapboxGl.jsx → src/components/MapMaplibreGl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import PropTypes from 'prop-types'
import ReactDOM from 'react-dom'
import MapLibreGl from 'maplibre-gl'
import MapboxInspect from 'mapbox-gl-inspect'
import MapMapboxGlLayerPopup from './MapMapboxGlLayerPopup'
import MapMapboxGlFeaturePropertyPopup from './MapMapboxGlFeaturePropertyPopup'
import MapMaplibreGlLayerPopup from './MapMaplibreGlLayerPopup'
import MapMaplibreGlFeaturePropertyPopup from './MapMaplibreGlFeaturePropertyPopup'
import tokens from '../config/tokens.json'
import colors from 'mapbox-gl-inspect/lib/colors'
import Color from 'color'
import ZoomControl from '../libs/zoomcontrol'
import { colorHighlightedLayer } from '../libs/highlight'
import 'maplibre-gl/dist/maplibre-gl.css'
import '../mapboxgl.css'
import '../libs/mapbox-rtl'
import '../maplibregl.css'
import '../libs/maplibre-rtl'


const IS_SUPPORTED = MapLibreGl.supported();
Expand Down Expand Up @@ -52,7 +52,7 @@ function buildInspectStyle(originalMapStyle, coloredLayers, highlightedLayer) {
return inspectStyle
}

export default class MapMapboxGl extends React.Component {
export default class MapMaplibreGl extends React.Component {
static propTypes = {
onDataChange: PropTypes.func,
onLayerSelect: PropTypes.func.isRequired,
Expand All @@ -69,7 +69,6 @@ export default class MapMapboxGl extends React.Component {
onDataChange: () => {},
onLayerSelect: () => {},
onChange: () => {},
mapboxAccessToken: tokens.mapbox,
options: {},
}

Expand All @@ -86,7 +85,7 @@ export default class MapMapboxGl extends React.Component {

if(!this.state.map) return

//Mapbox GL now does diffing natively so we don't need to calculate
//Maplibre GL now does diffing natively so we don't need to calculate
//the necessary operations ourselves!
this.state.map.setStyle(
this.props.replaceAccessTokens(props.mapStyle),
Expand Down Expand Up @@ -120,7 +119,7 @@ export default class MapMapboxGl extends React.Component {
if (map) {
if (this.props.inspectModeEnabled) {
// HACK: We need to work out why we need to do this and what's causing
// this error. I'm assuming an issue with mapbox-gl update and
// this error. I'm assuming an issue with maplibre-gl update and
// mapbox-gl-inspect.
try {
this.state.inspect.render();
Expand Down Expand Up @@ -182,9 +181,9 @@ export default class MapMapboxGl extends React.Component {
buildInspectStyle: (originalMapStyle, coloredLayers) => buildInspectStyle(originalMapStyle, coloredLayers, this.props.highlightedLayer),
renderPopup: features => {
if(this.props.inspectModeEnabled) {
return renderPopup(<MapMapboxGlFeaturePropertyPopup features={features} />, tmpNode);
return renderPopup(<MapMaplibreGlFeaturePropertyPopup features={features} />, tmpNode);
} else {
return renderPopup(<MapMapboxGlLayerPopup features={features} onLayerSelect={this.onLayerSelectById} zoom={this.state.zoom} />, tmpNode);
return renderPopup(<MapMaplibreGlLayerPopup features={features} onLayerSelect={this.onLayerSelectById} zoom={this.state.zoom} />, tmpNode);
}
}
})
Expand Down Expand Up @@ -238,7 +237,7 @@ export default class MapMapboxGl extends React.Component {
className="maputnik-map maputnik-map--error"
>
<div className="maputnik-map__error-message">
Error: Cannot load MapboxGL, WebGL is either unsupported or disabled
Error: Cannot load MaplibreGL, WebGL is either unsupported or disabled
</div>
</div>
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/MapOpenLayers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {throttle} from 'lodash';
import PropTypes from 'prop-types'
import { loadJSON } from '../libs/urlopen'

import MapMapboxGlLayerPopup from './MapMapboxGlLayerPopup';
import MapMaplibreGlLayerPopup from './MapMaplibreGlLayerPopup';

import 'ol/ol.css'
import {apply} from 'ol-mapbox-style';
Expand Down Expand Up @@ -146,13 +146,13 @@ export default class MapOpenLayers extends React.Component {
className="maputnik-popup"
>
<button
className="mapboxgl-popup-close-button"
className="maplibregl-popup-close-button"
onClick={this.closeOverlay}
aria-label="Close popup"
>
×
</button>
<MapMapboxGlLayerPopup
<MapMaplibreGlLayerPopup
features={this.state.selectedFeatures || []}
onLayerSelect={this.props.onLayerSelect}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/ModalDebug.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class ModalDebug extends React.Component {
onChangeMaboxGlDebug: PropTypes.func.isRequired,
onChangeOpenlayersDebug: PropTypes.func.isRequired,
onOpenToggle: PropTypes.func.isRequired,
mapboxGlDebugOptions: PropTypes.object,
maplibreGlDebugOptions: PropTypes.object,
openlayersDebugOptions: PropTypes.object,
mapView: PropTypes.object,
}
Expand All @@ -31,9 +31,9 @@ export default class ModalDebug extends React.Component {
>
<section className="maputnik-modal-section maputnik-modal-shortcuts">
<h1>Options</h1>
{this.props.renderer === 'mbgljs' &&
{this.props.renderer === 'mlgljs' &&
<ul>
{Object.entries(this.props.mapboxGlDebugOptions).map(([key, val]) => {
{Object.entries(this.props.maplibreGlDebugOptions).map(([key, val]) => {
return <li key={key}>
<label>
<input type="checkbox" checked={val} onClick={(e) => this.props.onChangeMaboxGlDebug(key, e.target.checked)} /> {key}
Expand Down
17 changes: 5 additions & 12 deletions src/components/ModalExport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import style from '../libs/style'
import fieldSpecAdditional from '../libs/field-spec-additional'


const MAPBOX_GL_VERSION = pkgLockJson.dependencies["mapbox-gl"].version;
const MAPLIBRE_GL_VERSION = pkgLockJson.dependencies["maplibre-gl"].version;


export default class ModalExport extends React.Component {
Expand Down Expand Up @@ -58,8 +58,8 @@ export default class ModalExport extends React.Component {
<meta charset="utf-8" />
<title>${htmlTitle}</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v${MAPBOX_GL_VERSION}/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v${MAPBOX_GL_VERSION}/mapbox-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/maplibre-gl@${MAPLIBRE_GL_VERSION}/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@${MAPLIBRE_GL_VERSION}/dist/maplibre-gl.css" rel="stylesheet" />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
Expand All @@ -68,12 +68,11 @@ export default class ModalExport extends React.Component {
<body>
<div id="map"></div>
<script>
mapboxgl.accessToken = 'access_token';
const map = new mapboxgl.Map({
const map = new maplibregl.Map({
container: 'map',
style: ${tokenStyle},
});
map.addControl(new mapboxgl.NavigationControl());
map.addControl(new maplibregl.NavigationControl());
</script>
</body>
</html>
Expand Down Expand Up @@ -119,12 +118,6 @@ export default class ModalExport extends React.Component {
</p>

<div>
<FieldString
label={fieldSpecAdditional.maputnik.mapbox_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.mapbox_access_token}
value={(this.props.mapStyle.metadata || {})['maputnik:mapbox_access_token']}
onChange={this.changeMetadataProperty.bind(this, "maputnik:mapbox_access_token")}
/>
<FieldString
label={fieldSpecAdditional.maputnik.maptiler_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.maptiler_access_token}
Expand Down
12 changes: 2 additions & 10 deletions src/components/ModalSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ export default class ModalSettings extends React.Component {
onChange={this.changeStyleProperty.bind(this, "glyphs")}
/>

<FieldString {...inputProps}
label={fieldSpecAdditional.maputnik.mapbox_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.mapbox_access_token}
data-wd-key="modal:settings.maputnik:mapbox_access_token"
value={metadata['maputnik:mapbox_access_token']}
onChange={onChangeMetadataProperty.bind(this, "maputnik:mapbox_access_token")}
/>

<FieldString {...inputProps}
label={fieldSpecAdditional.maputnik.maptiler_access_token.label}
fieldSpec={fieldSpecAdditional.maputnik.maptiler_access_token}
Expand Down Expand Up @@ -241,10 +233,10 @@ export default class ModalSettings extends React.Component {
fieldSpec={fieldSpecAdditional.maputnik.style_renderer}
data-wd-key="modal:settings.maputnik:renderer"
options={[
['mbgljs', 'MapboxGL JS'],
['mlgljs', 'MapLibreGL JS'],
['ol', 'Open Layers (experimental)'],
]}
value={metadata['maputnik:renderer'] || 'mbgljs'}
value={metadata['maputnik:renderer'] || 'mlgljs'}
onChange={onChangeMetadataProperty.bind(this, 'maputnik:renderer')}
/>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/config/tokens.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"mapbox": "pk.eyJ1IjoibW9yZ2Vua2FmZmVlIiwiYSI6ImNpeHJmNXNmZTAwNHIycXBid2NqdTJibjMifQ.Dv1-GDpTWi0NP6xW9Fct1w",
"openmaptiles": "KDhMfHvorAFkFe64wlZb",
"thunderforest": "b71f7f0ba4064f5eb9e903859a9cf5c6"
}
4 changes: 0 additions & 4 deletions src/libs/field-spec-additional.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const spec = {
maputnik: {
mapbox_access_token: {
label: "Mapbox Access Token",
doc: "Public access token for Mapbox services."
},
maptiler_access_token: {
label: "MapTiler Access Token",
doc: "Public access token for MapTiler Cloud."
Expand Down
2 changes: 1 addition & 1 deletion src/libs/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function changeProperty(layer, group, property, newValue) {
if(group) {
const newLayer = {
...layer,
// Change object so the diff works in ./src/components/map/MapboxGlMap.jsx
// Change object so the diff works in ./src/components/map/MaplibreGlMap.jsx
[group]: {
...layer[group]
}
Expand Down
Loading
Loading