Skip to content

Bump mapbox-gl to v0.22.0 #867

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

Merged
merged 4 commits into from
Aug 22, 2016
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"gl-select-box": "^1.0.1",
"gl-spikes2d": "^1.0.1",
"gl-surface3d": "^1.2.3",
"mapbox-gl": "^0.18.0",
"mapbox-gl": "^0.22.0",
"mouse-change": "^1.1.1",
"mouse-wheel": "^1.0.2",
"ndarray": "^1.0.16",
Expand Down
20 changes: 14 additions & 6 deletions src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,24 @@ proto.toImage = function() {

// convenience wrapper to create blank GeoJSON sources
// and avoid 'invalid GeoJSON' errors
proto.createGeoJSONSource = function() {
proto.initSource = function(idSource) {
var blank = {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: []
type: 'geojson',
data: {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: []
}
}
};

return new mapboxgl.GeoJSONSource({data: blank});
return this.map.addSource(idSource, blank);
};

// convenience wrapper to set data of GeoJSON sources
proto.setSourceData = function(idSource, data) {
this.map.getSource(idSource).setData(data);
};

// convenience wrapper to create set multiple layer
Expand Down
16 changes: 14 additions & 2 deletions src/traces/scattermapbox/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,21 @@ function makeBlankGeoJSON() {
}

function makeFillGeoJSON(_, coords) {
if(coords.length === 1) {
return {
type: 'Polygon',
coordinates: coords
};
}

var _coords = new Array(coords.length);
for(var i = 0; i < coords.length; i++) {
_coords[i] = [coords[i]];
}

return {
type: 'Polygon',
coordinates: coords
type: 'MultiPolygon',
coordinates: _coords
};
}

Expand Down
24 changes: 8 additions & 16 deletions src/traces/scattermapbox/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,10 @@ function ScatterMapbox(mapbox, uid) {
this.idLayerCircle = uid + '-layer-circle';
this.idLayerSymbol = uid + '-layer-symbol';

this.sourceFill = mapbox.createGeoJSONSource();
this.map.addSource(this.idSourceFill, this.sourceFill);

this.sourceLine = mapbox.createGeoJSONSource();
this.map.addSource(this.idSourceLine, this.sourceLine);

this.sourceCircle = mapbox.createGeoJSONSource();
this.map.addSource(this.idSourceCircle, this.sourceCircle);

this.sourceSymbol = mapbox.createGeoJSONSource();
this.map.addSource(this.idSourceSymbol, this.sourceSymbol);
this.mapbox.initSource(this.idSourceFill);
this.mapbox.initSource(this.idSourceLine);
this.mapbox.initSource(this.idSourceCircle);
this.mapbox.initSource(this.idSourceSymbol);

this.map.addLayer({
id: this.idLayerFill,
Expand Down Expand Up @@ -73,7 +66,6 @@ var proto = ScatterMapbox.prototype;

proto.update = function update(calcTrace) {
var mapbox = this.mapbox;

var opts = convert(calcTrace);

mapbox.setOptions(this.idLayerFill, 'setLayoutProperty', opts.fill.layout);
Expand All @@ -82,22 +74,22 @@ proto.update = function update(calcTrace) {
mapbox.setOptions(this.idLayerSymbol, 'setLayoutProperty', opts.symbol.layout);

if(isVisible(opts.fill)) {
this.sourceFill.setData(opts.fill.geojson);
mapbox.setSourceData(this.idSourceFill, opts.fill.geojson);
mapbox.setOptions(this.idLayerFill, 'setPaintProperty', opts.fill.paint);
}

if(isVisible(opts.line)) {
this.sourceLine.setData(opts.line.geojson);
mapbox.setSourceData(this.idSourceLine, opts.line.geojson);
mapbox.setOptions(this.idLayerLine, 'setPaintProperty', opts.line.paint);
}

if(isVisible(opts.circle)) {
this.sourceCircle.setData(opts.circle.geojson);
mapbox.setSourceData(this.idSourceCircle, opts.circle.geojson);
mapbox.setOptions(this.idLayerCircle, 'setPaintProperty', opts.circle.paint);
}

if(isVisible(opts.symbol)) {
this.sourceSymbol.setData(opts.symbol.geojson);
mapbox.setSourceData(this.idSourceSymbol, opts.symbol.geojson);
mapbox.setOptions(this.idLayerSymbol, 'setPaintProperty', opts.symbol.paint);
}
};
Expand Down
Binary file modified test/image/baselines/mapbox_angles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_custom-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions test/jasmine/tests/scattermapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@ describe('scattermapbox convert', function() {

assertVisibility(opts, ['visible', 'visible', 'visible', 'none']);

var lineCoords = [[
[10, 20], [20, 20], [30, 10]
], [
[20, 10], [10, 20]
]];
var segment1 = [[10, 20], [20, 20], [30, 10]],
segment2 = [[20, 10], [10, 20]];

var lineCoords = [segment1, segment2],
fillCoords = [[segment1], [segment2]];

expect(opts.fill.geojson.coordinates).toEqual(lineCoords, 'have correct fill coords');
expect(opts.line.geojson.coordinates).toEqual(lineCoords, 'have correct line coords');
expect(opts.fill.geojson.coordinates).toEqual(fillCoords, 'have correct fill coords');

var circleCoords = opts.circle.geojson.features.map(function(f) {
return f.geometry.coordinates;
Expand Down