forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variable-anchor-with-icon-text-fit.html
132 lines (129 loc) · 3.24 KB
/
variable-anchor-with-icon-text-fit.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<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 places = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"description": "Ford's Theater",
"icon": "theatre"
},
"geometry": {
"type": "Point",
"coordinates": [-77.038659, 38.931567]
}
}, {
"type": "Feature",
"properties": {
"description": "The Gaslight",
"icon": "theatre"
},
"geometry": {
"type": "Point",
"coordinates": [-77.003168, 38.894651]
}
}, {
"type": "Feature",
"properties": {
"description": "Horrible Harry's",
"icon": "bar"
},
"geometry": {
"type": "Point",
"coordinates": [-77.090372, 38.881189]
}
}, {
"type": "Feature",
"properties": {
"description": "Bike Party",
"icon": "bicycle"
},
"geometry": {
"type": "Point",
"coordinates": [-77.052477, 38.943951]
}
}, {
"type": "Feature",
"properties": {
"description": "Rockabilly Rockstars",
"icon": "music"
},
"geometry": {
"type": "Point",
"coordinates": [-77.031706, 38.914581]
}
}, {
"type": "Feature",
"properties": {
"description": "District Drum Tribe",
"icon": "music"
},
"geometry": {
"type": "Point",
"coordinates": [-77.020945, 38.878241]
}
}, {
"type": "Feature",
"properties": {
"description": "Motown Memories",
"icon": "music"
},
"geometry": {
"type": "Point",
"coordinates": [-77.007481, 38.876516]
}
}]
};
var style = {
version: 8,
center: [-77.04, 38.907],
zoom: 12,
sources: {
places: {
type: 'geojson',
data: places,
}
},
sprite: 'mapbox:https://sprites/mapbox/streets-v11',
glyphs: "mapbox:https://fonts/mapbox/{fontstack}/{range}.pbf",
layers: [{
id: 'foo',
type: 'symbol',
source: 'places',
layout: {
'icon-image': 'rectangle-orange-6',
'text-field': ['get', 'description'],
'text-size': 12.5,
'text-variable-anchor': ['left', 'right', 'bottom', 'top'],
'text-justify': 'auto',
'icon-text-fit': 'width',
'icon-text-fit-padding': [0, 5, 1, 5]
},
paint: {
'text-color': '#3C77C0'
}
}]
};
var map = window.map = new mapboxgl.Map({
container: 'map',
style
});
</script>
</body>
</html>