Get map rendering with maplibre

This commit is contained in:
Kevin Schaul 2023-07-12 16:37:19 -05:00
parent 8e329a0ff9
commit 8e0546fba4
2 changed files with 5 additions and 8 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "maputnik", "name": "maputnik",
"version": "2.0.0", "version": "2.0.0-pre.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "maputnik", "name": "maputnik",
"version": "2.0.0", "version": "2.0.0-pre.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.17.9", "@babel/runtime": "^7.17.9",

View file

@ -75,7 +75,6 @@ export default class MapMapboxGl extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
MapboxGl.accessToken = tokens.mapbox
this.state = { this.state = {
map: null, map: null,
inspect: null, inspect: null,
@ -86,8 +85,6 @@ export default class MapMapboxGl extends React.Component {
if(!IS_SUPPORTED) return; if(!IS_SUPPORTED) return;
if(!this.state.map) return if(!this.state.map) return
const metadata = props.mapStyle.metadata || {}
MapboxGl.accessToken = metadata['maputnik:mapbox_access_token'] || tokens.mapbox
//Mapbox GL now does diffing natively so we don't need to calculate //Mapbox GL now does diffing natively so we don't need to calculate
//the necessary operations ourselves! //the necessary operations ourselves!
@ -149,7 +146,7 @@ export default class MapMapboxGl extends React.Component {
maxZoom: 24 maxZoom: 24
} }
const map = new MapboxGl.Map(mapOpts); const map = new MapLibreGl.Map(mapOpts);
const mapViewChange = () => { const mapViewChange = () => {
const center = map.getCenter(); const center = map.getCenter();
@ -165,13 +162,13 @@ export default class MapMapboxGl extends React.Component {
const zoomControl = new ZoomControl; const zoomControl = new ZoomControl;
map.addControl(zoomControl, 'top-right'); map.addControl(zoomControl, 'top-right');
const nav = new MapboxGl.NavigationControl({visualizePitch:true}); const nav = new MapLibreGl.NavigationControl({visualizePitch:true});
map.addControl(nav, 'top-right'); map.addControl(nav, 'top-right');
const tmpNode = document.createElement('div'); const tmpNode = document.createElement('div');
const inspect = new MapboxInspect({ const inspect = new MapboxInspect({
popup: new MapboxGl.Popup({ popup: new MapLibreGl.Popup({
closeOnClick: false closeOnClick: false
}), }),
showMapPopup: true, showMapPopup: true,