Skip to content

Commit

Permalink
Mapbox vector layer
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed May 3, 2020
1 parent fcc9163 commit 4d99757
Show file tree
Hide file tree
Showing 20 changed files with 4,642 additions and 33 deletions.
5 changes: 5 additions & 0 deletions config/jsdoc/api/plugins/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ exports.handlers = {
processingComplete(e) {
const byLongname = e.doclets.index.longname;
for (const name in defaultExports) {
if (!(name in byLongname)) {
throw new Error(
`missing ${name} in doclet index, did you forget a @module tag?`
);
}
byLongname[name].forEach(function (doclet) {
doclet.isDefaultExport = true;
});
Expand Down
3 changes: 3 additions & 0 deletions examples/mapbox-vector-layer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.map {
background: #f8f4f0;
}
15 changes: 15 additions & 0 deletions examples/mapbox-vector-layer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
layout: example.html
title: Mapbox Vector Layer
shortdesc: Rendering a layer with a Mapbox-hosted style.
docs: >
The MapboxVector layer allows you to create a layer based on a Mapbox-hosted style using a single
vector source. If your style uses more than one source, use the `source` property to choose a
single vector source. Use the `layers` property if you only want to render a subset of the style's
layers (provided they all share the same source).
tags: "mapbox, studio, vector, tiles"
cloak:
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
value: Your Mapbox access token from https://mapbox.com/ here
---
<div id="map" class="map"></div>
18 changes: 18 additions & 0 deletions examples/mapbox-vector-layer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Map from '../src/ol/Map.js';
import MapboxVector from '../src/ol/layer/MapboxVector.js';
import View from '../src/ol/View.js';

const map = new Map({
target: 'map',
layers: [
new MapboxVector({
styleUrl: 'mapbox://styles/mapbox/bright-v9',
accessToken:
'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q',
}),
],
view: new View({
center: [0, 0],
zoom: 2,
}),
});
36 changes: 11 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"dependencies": {
"elm-pep": "^1.0.4",
"ol-mapbox-style": "^6.1.1",
"pbf": "3.2.1",
"pixelworks": "1.1.0",
"rbush": "^3.0.1"
Expand Down Expand Up @@ -85,7 +86,6 @@
"loglevelnext": "^4.0.1",
"marked": "1.0.0",
"mocha": "7.1.2",
"ol-mapbox-style": "^6.1.1",
"pixelmatch": "^5.1.0",
"pngjs": "^5.0.0",
"proj4": "2.6.1",
Expand Down
Binary file added rendering/cases/layer-mapbox-vector/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions rendering/cases/layer-mapbox-vector/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Map from '../../../src/ol/Map.js';
import MapboxVector from '../../../src/ol/layer/MapboxVector.js';
import View from '../../../src/ol/View.js';

new Map({
layers: [
new MapboxVector({
styleUrl: '/data/styles/bright-v9.json',
accessToken: 'test-token',
}),
],
target: 'map',
view: new View({
center: [1825927.7316762917, 6143091.089223046],
zoom: 15,
}),
});

render({
message: 'Mapbox vector layer renders',
tolerance: 0.025,
});
Loading

0 comments on commit 4d99757

Please sign in to comment.