To use this test case:
- download the zip file of this gist
npm install
oryarn
to download dependencies- edit
node_modules/mapbox-gl/package.json
somain: "src/index.js"
open index.html
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<meta charset=utf-8 /> | |
<title>Test | Mapbox</title> | |
<link href='https://api.mapbox.com/mapbox-assembly/v0.10.1/assembly.min.css' rel='stylesheet' /> | |
<script async defer src="https://api.mapbox.com/mapbox-assembly/v0.10.1/assembly.js"></script> | |
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.34.0/mapbox-gl.css' rel='stylesheet' /> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
} | |
#map { | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="bundle.js"></script> | |
</body> | |
</html> | |
import mapboxgl from 'mapbox-gl'; | |
mapboxgl.accessToken = 'pk.eyJ1IjoibW9sbHltZXJwIiwiYSI6ImNpazdqbGtiZTAxbGNocm0ybXJ3MnNzOHAifQ.5_kJrEENbBWtqTZEv7g1-w'; | |
const map = new mapboxgl.Map({ | |
container: 'map', | |
style: 'mapbox://styles/mapbox/light-v9' | |
}) |
{ | |
"name": "test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"build": "browserify index.js > bundle.js", | |
"webpack-client": "webpack --config ./webpack.config.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"browserify": "^14.1.0", | |
"mapbox-gl": "^0.34.0", | |
"webpack": "^2.2.1" | |
} | |
} |
var debug = process.env.NODE_ENV !== "production"; | |
var webpack = require('webpack'); | |
var path = require('path'); | |
module.exports = { | |
context: __dirname, | |
devtool: debug ? "inline-sourcemap" : null, | |
entry: "./index.js", | |
output: { | |
filename: "bundle.js" | |
}, | |
plugins: debug ? [] : [ | |
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.OccurenceOrderPlugin(), | |
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }), | |
], | |
resolve: { | |
alias: { | |
"mapbox-gl": path.resolve(__dirname, './node_modules/mapbox-gl/dist/mapbox-gl.js') | |
} | |
} | |
}; |