Skip to content

Commit

Permalink
showCollisionBoxes fix (mapbox#4689)
Browse files Browse the repository at this point in the history
* fire  when redoing placement so collision boxes show up when map.showCollisionBoxes is set to true

* add collision box test

* make render tests consistent
  • Loading branch information
mollymerp authored and chrisvoll committed May 25, 2017
1 parent 8fd3339 commit 061ac1c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Tile {
showCollisionBoxes: source.map.showCollisionBoxes
}, (_, data) => {
this.reloadSymbolData(data, source.map.style);

if (source.map.showCollisionBoxes) source.fire('data', {tile: this, coord: this.coord, dataType: 'source'});
// HACK this is nescessary to fix https://github.com/mapbox/mapbox-gl-js/issues/2986
if (source.map) source.map.painter.tileExtentVAO.vao = null;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"version": 8,
"metadata": {
"test": {
"height": 64,
"width": 64,
"collisionDebug":true
}
},
"center": [ 0, 0 ],
"zoom": 0,
"sources": {
"point": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [ 0, 0 ]
}
}
]
}
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "text",
"type": "symbol",
"source": "point",
"layout": {
"text-field": "Test",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
]
}
}
]
}
5 changes: 4 additions & 1 deletion test/suite_implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ module.exports = function(style, options, _callback) {
map.repaint = true;

if (options.debug) map.showTileBoundaries = true;
if (options.collisionDebug) map.showCollisionBoxes = true;
if (options.showOverdrawInspector) map.showOverdrawInspector = true;

const gl = map.painter.gl;

map.once('load', () => {
if (options.collisionDebug) {
map.showCollisionBoxes = true;
options.operations = [["wait"]];
}
applyOperations(map, options.operations, () => {
const w = options.width * window.devicePixelRatio;
const h = options.height * window.devicePixelRatio;
Expand Down

0 comments on commit 061ac1c

Please sign in to comment.