-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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-size
- Loading branch information
Anand Thakker
committed
Mar 23, 2017
1 parent
752c39a
commit 23e2b51
Showing
8 changed files
with
291 additions
and
47 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,120 @@ | ||
<!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, | ||
"text-max-angle": 180, | ||
"text-field": "abcdefghijklmnopqrstuvwxyz", | ||
"text-font": [ | ||
"Open Sans Semibold", | ||
"Arial Unicode MS Bold" | ||
], | ||
"text-size": textSize | ||
}, | ||
"paint": { "text-color": color } | ||
}); | ||
|
||
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 ] | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
|
||
"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
Oops, something went wrong.