-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable property functions for {text,icon}-size (#4455)
* Refactor byte pair unpacking into separate shader function * Document / clarify StyleDeclaration#calculateInterpolationT * Document strategy for populating vertex attributes with composite function values * Clamp composite function interpolation to [0, 3], not [0, 4] * Refactor {Array,Buffer}Group to construct layout vertex array type dynamically * Enable property functions for text-size * Improve naming and symbol layout internal docs * Enable property functions for icon-size * Add render tests for data-driven {text,icon}-size * Pack texture and layout data into single attribute Fix bug in packing of labelangle value * Label angles passed to addVertex() are in units of 1/256 of a circle. Because packUint8ToFloat clamped input values to [0, 255], the value 256 was clamped to 255 (== 1.4 degrees off the horizontal), rather than being wrapped to 0. * Remove vestigial parameters * Refactor {text,icon}-size-related bucket data - Consolidate it under bucket.{text,icon}SizeData objects - Include function base as part of said data - Use interpolationFactor to account for base != 1 for consistency with paint properties * Document and refactor exponential function interpolation * Fix handling of camera functions of 'interval' type * Add t.equalWithPrecision() assertion and use it for function tests * Edit comment for accuracy * Ignore high-base tests for native mapbox/mapbox-gl-native#8654 * Fixup render test: add missing feature properties
- Loading branch information
1 parent
1cc4089
commit 13363a2
Showing
58 changed files
with
1,700 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Mapbox GL JS debug page</title> | ||
<meta charset='utf-8'> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | ||
<link rel='stylesheet' href='/dist/mapbox-gl.css' /> | ||
<style> | ||
body { margin: 0; padding: 0; } | ||
html, body, #map { height: 100%; } | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id='map'></div> | ||
|
||
<script src='/dist/mapbox-gl-dev.js'></script> | ||
<script src='/debug/access_token_generated.js'></script> | ||
<script> | ||
var stops = [ | ||
[ 0, 6 ], | ||
[ 1, 6 ], | ||
[ 2, 6 ], | ||
[ 2.1, 3 ], | ||
[ 2.2, 3 ], | ||
[ 2.3, 3 ], | ||
[ 2.4, 3 ], | ||
[ 3, 12 ], | ||
[ 10, 12 ] | ||
]; | ||
|
||
var layer = (id, x, textSize, color) => ({ | ||
"id": id, | ||
"type": "symbol", | ||
"source": "geojson", | ||
"filter": ["==", "x", x], | ||
"layout": { | ||
"symbol-placement": "line", | ||
"symbol-spacing": 1, | ||
"text-anchor": "left", | ||
"text-allow-overlap": true, | ||
"text-ignore-placement": true, | ||
"icon-allow-overlap": true, | ||
"icon-ignore-placement": true, | ||
"text-max-angle": 180, | ||
"text-field": "abcdefghijklmnopqrstuvwxyz", | ||
"text-font": [ | ||
"Open Sans Semibold", | ||
"Arial Unicode MS Bold" | ||
], | ||
"text-size": textSize, | ||
"icon-size": Object.assign({}, textSize, { | ||
stops: textSize.stops.map(s => [s[0], s[1] / 3]) | ||
}), | ||
"icon-image": "airfield-11" | ||
}, | ||
"paint": { | ||
"text-color": color, | ||
"text-opacity": 0.5 | ||
} | ||
}); | ||
|
||
var style = { | ||
"version": 8, | ||
"metadata": { | ||
"test": { | ||
"width": 64, | ||
"height": 64 | ||
} | ||
}, | ||
"sources": { | ||
"geojson": { | ||
"type": "geojson", | ||
"data": { | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { "x": 0 }, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[ -10, -1 ], | ||
[ -20, -10 ], | ||
[ -30, -1 ], | ||
[ -40, -10 ] | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"sprite": "mapbox://sprites/mapbox/streets-v10", | ||
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf", | ||
"layers": [ | ||
layer('symbol-camera', 0, { | ||
"stops": stops | ||
}, 'red'), | ||
|
||
layer('symbol-composite', 0, { | ||
"property": "x", | ||
"stops": stops.map(s => [{value: 0, zoom: s[0]}, s[1]]) | ||
}, 'blue'), | ||
|
||
{ | ||
"id": "line", | ||
"type": "line", | ||
"source": "geojson" | ||
} | ||
] | ||
}; | ||
|
||
var map = window.map = new mapboxgl.Map({ | ||
container: 'map', | ||
zoom: 12.5, | ||
center: [-77.01866, 38.888], | ||
style: style, | ||
hash: true | ||
}); | ||
|
||
map.showTileBoundaries = true; | ||
|
||
setTimeout(() => console.log(JSON.stringify(map.getStyle()))); | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.