@abi-software/flatmap-viewer 2.7.1-a.1 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/interactions.js +0 -6
- package/src/layers/cluster.js +1 -4
- package/src/layers/index.js +1 -5
- package/src/main.js +2 -11
- package/src/utils.js +0 -1
- package/thirdParty/maplibre-gl-svg/CHANGELOG.md +13 -0
- package/thirdParty/maplibre-gl-svg/LICENSE +21 -0
- package/thirdParty/maplibre-gl-svg/LICENSE.md +21 -0
- package/thirdParty/maplibre-gl-svg/README.md +24 -0
- package/thirdParty/maplibre-gl-svg/assets/Add custom SVG template to template manager.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as HTML markers.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/All built-in SVG templates as symbols.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Fill polygon with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with Custom SVG Template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/HTML Marker with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Line layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Load SVG from URL.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/SVG template options.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/Smiley_face_changed.svg +37 -0
- package/thirdParty/maplibre-gl-svg/assets/Symbol layer with built-in SVG template.jpg +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up-thin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/car.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker-rotated.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/checker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles-spaced.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/circles.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-lines-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-down.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/diagonal-stripes-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/dots.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag-triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/flag.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/hexagon.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-arrow.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-ball-pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-circle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-flat.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded-cluster.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square-rounded.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/marker.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin-round.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/pin.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-lines.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rotated-grid-stripes.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/rounded-square.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-left.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-arrow-up.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle-thick.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/triangle.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/x-fill.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag-vertical.png +0 -0
- package/thirdParty/maplibre-gl-svg/assets/image-templates/zig-zag.png +0 -0
- package/thirdParty/maplibre-gl-svg/build/build.js +210 -0
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.js +339 -0
- package/thirdParty/maplibre-gl-svg/dist/maplibre-gl-svg.min.js +4 -0
- package/thirdParty/maplibre-gl-svg/docs/docs.md +375 -0
- package/thirdParty/maplibre-gl-svg/examples/Add custom SVG template to template manager.html +101 -0
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as HTML markers.html +82 -0
- package/thirdParty/maplibre-gl-svg/examples/All built-in SVG templates as symbols.html +124 -0
- package/thirdParty/maplibre-gl-svg/examples/Fill polygon with built-in SVG template.html +94 -0
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with Custom SVG Template.html +86 -0
- package/thirdParty/maplibre-gl-svg/examples/HTML Marker with built-in SVG template.html +83 -0
- package/thirdParty/maplibre-gl-svg/examples/Line layer with built-in SVG template.html +129 -0
- package/thirdParty/maplibre-gl-svg/examples/Load SVG from URL.html +96 -0
- package/thirdParty/maplibre-gl-svg/examples/SVG template options.html +264 -0
- package/thirdParty/maplibre-gl-svg/examples/Symbol layer with built-in SVG template.html +93 -0
- package/thirdParty/maplibre-gl-svg/index.html +151 -0
- package/thirdParty/maplibre-gl-svg/package-lock.json +5882 -0
- package/thirdParty/maplibre-gl-svg/package.json +49 -0
- package/thirdParty/maplibre-gl-svg/src/SvgManager.ts +186 -0
- package/thirdParty/maplibre-gl-svg/src/SvgTemplateManager.ts +144 -0
- package/thirdParty/maplibre-gl-svg/src/index.ts +4 -0
- package/thirdParty/maplibre-gl-svg/tsconfig.json +31 -0
- package/thirdParty/maplibre-gl-svg/typings/index.d.ts +111 -0
- package/src/types.ts +0 -26
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title>SVG template options</title>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<link rel='stylesheet' href='https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css' />
|
|
8
|
+
<script src='https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
|
9
|
+
|
|
10
|
+
<script src="../dist/maplibre-gl-svg.js"></script>
|
|
11
|
+
|
|
12
|
+
<style>
|
|
13
|
+
body { margin: 0; padding: 0; }
|
|
14
|
+
html, body { height: 100%; }
|
|
15
|
+
#map { position: relative; width:100%; height:100%; }
|
|
16
|
+
fieldset { position: absolute; top: 10px; left: 10px; width: 300px;z-index: 1; background-color: white;}
|
|
17
|
+
legend {background-color: white;border-radius: 5px;border:1px solid #000;}
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="map"></div>
|
|
22
|
+
|
|
23
|
+
<fieldset>
|
|
24
|
+
<legend>SVG template options</legend>
|
|
25
|
+
This sample shows how the icon template options effect the rendering of built-in SVG templates.
|
|
26
|
+
|
|
27
|
+
<div>
|
|
28
|
+
<table>
|
|
29
|
+
<tr title="The method in which to use the images.">
|
|
30
|
+
<td>Layout:</td>
|
|
31
|
+
<td>
|
|
32
|
+
<input type="radio" name="layout" checked="checked" onclick="update('symbol')">Symbol icon<br>
|
|
33
|
+
<input type="radio" name="layout" onclick="update('line')">Line symbols<br>
|
|
34
|
+
<input type="radio" name="layout" onclick="update('polygon')">Polygon fill
|
|
35
|
+
</td>
|
|
36
|
+
</tr>
|
|
37
|
+
<tr title="The name of the template to use.">
|
|
38
|
+
<td>Template Name:</td>
|
|
39
|
+
<td>
|
|
40
|
+
<select id="TemplateNames" onchange="update()"></select>
|
|
41
|
+
</td>
|
|
42
|
+
</tr>
|
|
43
|
+
<tr title="The primary color for the template.">
|
|
44
|
+
<td>Primary Color:</td>
|
|
45
|
+
<td>
|
|
46
|
+
<input type="color" value="#1A73AA" id="PrimaryColor" onchange="update()" />
|
|
47
|
+
<input type="checkbox" id="PrimaryColorTransparent" onclick="update()" />Transparent
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
<tr title="The secondary color for the template.">
|
|
51
|
+
<td>Secondary Color:</td>
|
|
52
|
+
<td>
|
|
53
|
+
<input type="color" value="#ffffff" id="SecondaryColor" onchange="update()" />
|
|
54
|
+
<input type="checkbox" id="SecondaryColorTransparent" onclick="update()" />Transparent
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<tr title="The amount to scale the icon template by.">
|
|
58
|
+
<td>Scale:</td>
|
|
59
|
+
<td>
|
|
60
|
+
<form oninput="o.value=Scale.value">
|
|
61
|
+
<input type="range" id="Scale" value="1" min="0.1" max="5" step="0.1" oninput="update()" onchange="update()" />
|
|
62
|
+
<output name="o" for="Scale">1</output>
|
|
63
|
+
</form>
|
|
64
|
+
</td>
|
|
65
|
+
</tr>
|
|
66
|
+
</table>
|
|
67
|
+
</div>
|
|
68
|
+
</fieldset>
|
|
69
|
+
|
|
70
|
+
<script>
|
|
71
|
+
var marker, svgManager, layout = 'symbol';
|
|
72
|
+
|
|
73
|
+
var geojson = {
|
|
74
|
+
'type': 'FeatureCollection',
|
|
75
|
+
'features': [
|
|
76
|
+
{
|
|
77
|
+
'type': 'Feature',
|
|
78
|
+
'properties': {
|
|
79
|
+
},
|
|
80
|
+
'geometry': {
|
|
81
|
+
'type': 'Point',
|
|
82
|
+
'coordinates': [0,0]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const map = new maplibregl.Map({
|
|
89
|
+
container: 'map',
|
|
90
|
+
style: {
|
|
91
|
+
'version': 8,
|
|
92
|
+
'sources': {
|
|
93
|
+
'osm-tiles': {
|
|
94
|
+
'type': 'raster',
|
|
95
|
+
'tiles': [ 'https://tile.openstreetmap.org/{z}/{x}/{y}.png' ],
|
|
96
|
+
'tileSize': 256,
|
|
97
|
+
'attribution': '© <a href="https://www.openstreetmap.org/about" target="_blank">OpenStreetMap</a>'
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
'layers': [
|
|
101
|
+
{
|
|
102
|
+
'id': 'osm-tiles',
|
|
103
|
+
'type': 'raster',
|
|
104
|
+
'source': 'osm-tiles',
|
|
105
|
+
'minzoom': 0,
|
|
106
|
+
'maxzoom': 19
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
zoom: 2
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
//Load template names into UI.
|
|
114
|
+
var templateNames = maplibregl.SvgTemplateManager.getAllTemplateNames();
|
|
115
|
+
var html = [];
|
|
116
|
+
for (var i = 0; i < templateNames.length; i++) {
|
|
117
|
+
if (i === 0) {
|
|
118
|
+
html.push('<option value="', templateNames[i], '" selected="selected">', templateNames[i], '</option>');
|
|
119
|
+
} else {
|
|
120
|
+
html.push('<option value="', templateNames[i], '">', templateNames[i], '</option>');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
document.getElementById('TemplateNames').innerHTML = html.join('');
|
|
124
|
+
|
|
125
|
+
map.on('load', () => {
|
|
126
|
+
// Create a new instance of the SVG manager.
|
|
127
|
+
svgManager = new maplibregl.SvgManager(map);
|
|
128
|
+
|
|
129
|
+
// Create a source.
|
|
130
|
+
map.addSource('datasource', {
|
|
131
|
+
'type': 'geojson',
|
|
132
|
+
'data': geojson
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Add a layer to display a filled polygon.
|
|
136
|
+
map.addLayer({
|
|
137
|
+
'id': 'polygon-layer',
|
|
138
|
+
'type': 'fill',
|
|
139
|
+
'source': 'datasource',
|
|
140
|
+
'paint': {
|
|
141
|
+
// Apply the fill pattern.
|
|
142
|
+
'fill-pattern': 'myTemplatedImage',
|
|
143
|
+
'fill-opacity': 1
|
|
144
|
+
},
|
|
145
|
+
'filter': ['==', ['geometry-type'], 'Polygon']
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Add a line layer for displaying the line.
|
|
149
|
+
map.addLayer({
|
|
150
|
+
'id': 'line-layer',
|
|
151
|
+
'type': 'line',
|
|
152
|
+
'source': 'datasource',
|
|
153
|
+
'paint': {
|
|
154
|
+
// Apply the fill pattern.
|
|
155
|
+
'line-width': 5,
|
|
156
|
+
'line-color': 'Purple'
|
|
157
|
+
},
|
|
158
|
+
'filter': ['==', ['geometry-type'], 'LineString']
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
//Add a layer for symbols along the line.
|
|
162
|
+
map.addLayer({
|
|
163
|
+
'id': 'line-symbols',
|
|
164
|
+
'type': 'symbol',
|
|
165
|
+
'source': 'datasource',
|
|
166
|
+
'layout': {
|
|
167
|
+
//Reference the templated icon.
|
|
168
|
+
'icon-image': 'myTemplatedImage',
|
|
169
|
+
'icon-allow-overlap': true,
|
|
170
|
+
'symbol-placement': 'line',
|
|
171
|
+
'symbol-spacing': 100,
|
|
172
|
+
'icon-anchor': 'center'
|
|
173
|
+
},
|
|
174
|
+
'filter': ['==', ['geometry-type'], 'LineString']
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
//Add a layer to display points as symbols.
|
|
178
|
+
map.addLayer({
|
|
179
|
+
'id': 'point-symbols',
|
|
180
|
+
'type': 'symbol',
|
|
181
|
+
'source': 'datasource',
|
|
182
|
+
'layout': {
|
|
183
|
+
//Reference the templated icon.
|
|
184
|
+
'icon-image': 'myTemplatedImage',
|
|
185
|
+
'icon-allow-overlap': true,
|
|
186
|
+
'icon-anchor': 'center'
|
|
187
|
+
},
|
|
188
|
+
'filter': ['==', ['geometry-type'], 'Point']
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
update();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
function update(type) {
|
|
195
|
+
if (type) {
|
|
196
|
+
layout = type;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
//Get the primary and secondary color, and scale settings.
|
|
200
|
+
var color = document.getElementById('PrimaryColor').value;
|
|
201
|
+
var colorTransparent = document.getElementById('PrimaryColorTransparent').checked;
|
|
202
|
+
|
|
203
|
+
if (colorTransparent) {
|
|
204
|
+
color = 'transparent';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var sColor = document.getElementById('SecondaryColor').value;
|
|
208
|
+
var sColorTransparent = document.getElementById('SecondaryColorTransparent').checked;
|
|
209
|
+
|
|
210
|
+
if (sColorTransparent) {
|
|
211
|
+
sColor = 'transparent';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
var scale = parseFloat(document.getElementById('Scale').value);
|
|
215
|
+
|
|
216
|
+
//Get the template name.
|
|
217
|
+
var templateName = getSelectValue('TemplateNames');
|
|
218
|
+
|
|
219
|
+
// Remove the previously loaded template.
|
|
220
|
+
// Note that a warning will appear in the console about a missing image since we removed it temporarily.
|
|
221
|
+
if(svgManager.hasImage('myTemplatedImage')) {
|
|
222
|
+
svgManager.remove('myTemplatedImage');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Alternatively, since there is only one image, you can use svgManager.clear();
|
|
226
|
+
|
|
227
|
+
// Create the new image from a template.
|
|
228
|
+
svgManager.createFromTemplate('myTemplatedImage', templateName, color, sColor, scale).then(() => {
|
|
229
|
+
|
|
230
|
+
// Change the geometry as needed.
|
|
231
|
+
// This will also trigger a redraw of the map.
|
|
232
|
+
switch (layout) {
|
|
233
|
+
case 'symbol':
|
|
234
|
+
geojson.features[0].geometry = {
|
|
235
|
+
'type': 'Point',
|
|
236
|
+
'coordinates': [0,0]
|
|
237
|
+
};
|
|
238
|
+
break;
|
|
239
|
+
case 'line':
|
|
240
|
+
geojson.features[0].geometry = {
|
|
241
|
+
'type': 'LineString',
|
|
242
|
+
'coordinates': [[-50, -20], [0, 40], [50, -20]]
|
|
243
|
+
};
|
|
244
|
+
break;
|
|
245
|
+
case 'polygon':
|
|
246
|
+
geojson.features[0].geometry = {
|
|
247
|
+
'type': 'Polygon',
|
|
248
|
+
'coordinates': [[[-50, -20], [0, 40], [50, -20], [-50, -20]]]
|
|
249
|
+
};
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Update the source in the map
|
|
254
|
+
map.getSource('datasource').setData(geojson);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function getSelectValue(id) {
|
|
259
|
+
var elm = document.getElementById(id);
|
|
260
|
+
return elm.options[elm.selectedIndex].value;
|
|
261
|
+
}
|
|
262
|
+
</script>
|
|
263
|
+
</body>
|
|
264
|
+
</html>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title>Symbol layer with built-in SVG template</title>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<link rel='stylesheet' href='https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css' />
|
|
8
|
+
<script src='https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
|
9
|
+
|
|
10
|
+
<script src="../dist/maplibre-gl-svg.js"></script>
|
|
11
|
+
|
|
12
|
+
<style>
|
|
13
|
+
body { margin: 0; padding: 0; }
|
|
14
|
+
html, body { height: 100%; }
|
|
15
|
+
#map { position: relative; width:100%; height:100%; }
|
|
16
|
+
fieldset { position: absolute; top: 10px; left: 10px; width: 300px;z-index: 1; background-color: white;}
|
|
17
|
+
legend {background-color: white;border-radius: 5px;border:1px solid #000;}
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="map"></div>
|
|
22
|
+
|
|
23
|
+
<fieldset>
|
|
24
|
+
<legend>Symbol layer with built-in SVG template</legend>
|
|
25
|
+
This sample shows how to use an SVG template as an icon in a symbol layer.
|
|
26
|
+
</fieldset>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
var marker, svgManager;
|
|
30
|
+
|
|
31
|
+
const map = new maplibregl.Map({
|
|
32
|
+
container: 'map',
|
|
33
|
+
style: {
|
|
34
|
+
'version': 8,
|
|
35
|
+
'sources': {
|
|
36
|
+
'osm-tiles': {
|
|
37
|
+
'type': 'raster',
|
|
38
|
+
'tiles': [ 'https://tile.openstreetmap.org/{z}/{x}/{y}.png' ],
|
|
39
|
+
'tileSize': 256,
|
|
40
|
+
'attribution': '© <a href="https://www.openstreetmap.org/about" target="_blank">OpenStreetMap</a>'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
'layers': [
|
|
44
|
+
{
|
|
45
|
+
'id': 'osm-tiles',
|
|
46
|
+
'type': 'raster',
|
|
47
|
+
'source': 'osm-tiles',
|
|
48
|
+
'minzoom': 0,
|
|
49
|
+
'maxzoom': 19
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
zoom: 2
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
map.on('load', () => {
|
|
57
|
+
//Create a new instance of the SVG manager.
|
|
58
|
+
svgManager = new maplibregl.SvgManager(map);
|
|
59
|
+
|
|
60
|
+
//Load an SVG templated icon into the map.
|
|
61
|
+
svgManager.createFromTemplate('myTemplatedImage', 'marker-flat', 'teal', '#fff').then(() => {
|
|
62
|
+
|
|
63
|
+
//Add a layer to display a filled polygon.
|
|
64
|
+
map.addLayer({
|
|
65
|
+
'id': 'symbol-layer',
|
|
66
|
+
'type': 'symbol',
|
|
67
|
+
'source': {
|
|
68
|
+
'type': 'geojson',
|
|
69
|
+
'data': {
|
|
70
|
+
'type': 'FeatureCollection',
|
|
71
|
+
'features': [
|
|
72
|
+
{
|
|
73
|
+
'type': 'Feature',
|
|
74
|
+
'properties': {
|
|
75
|
+
},
|
|
76
|
+
'geometry': {
|
|
77
|
+
'type': 'Point',
|
|
78
|
+
'coordinates': [0,0]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
'layout': {
|
|
85
|
+
//Reference the templated icon.
|
|
86
|
+
'icon-image': 'myTemplatedImage'
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
</script>
|
|
92
|
+
</body>
|
|
93
|
+
</html>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title>MapLibre GL SVG Plugin - Examples</title>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 5px;
|
|
12
|
+
background-color: #dddddd;
|
|
13
|
+
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.card {
|
|
17
|
+
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
|
|
18
|
+
transition: 0.3s;
|
|
19
|
+
width: 250px;
|
|
20
|
+
margin:5px;
|
|
21
|
+
background-color: white;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.card:hover {
|
|
25
|
+
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.container {
|
|
29
|
+
padding: 2px 16px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.card-container {
|
|
33
|
+
display:flex;
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
</head>
|
|
39
|
+
<body>
|
|
40
|
+
<h1>MapLibre GL SVG Plugin</h1>
|
|
41
|
+
|
|
42
|
+
This is a <a href="https://maplibre.org/maplibre-gl-js/docs/" target="_blank">maplibre-gl-js</a> plugin that adds support for loading SVGs images into the maps image sprite.
|
|
43
|
+
It also includes a framework for templatable SVG images.
|
|
44
|
+
|
|
45
|
+
<h2>Examples</h2>
|
|
46
|
+
Check out the examples below:
|
|
47
|
+
<br/>
|
|
48
|
+
<br/>
|
|
49
|
+
<div class="card-container">
|
|
50
|
+
<div class="card">
|
|
51
|
+
<img src="assets/Load%20SVG%20from%20URL.jpg" style="width:100%">
|
|
52
|
+
<div class="container">
|
|
53
|
+
<h4><b>Load SVG from URL</b></h4>
|
|
54
|
+
<p>This sample shows how to load an SVG from a URL into the map and display it as a symbol. </p>
|
|
55
|
+
<a href="examples/Load%20SVG%20from%20URL.html" target="_blank">Run example</a> |
|
|
56
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/Load%20SVG%20from%20URL.html" target="_blank">Source code</a>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div class="card">
|
|
61
|
+
<img src="assets/SVG%20template%20options.jpg" style="width:100%">
|
|
62
|
+
<div class="container">
|
|
63
|
+
<h4><b>SVG template options</b></h4>
|
|
64
|
+
<p>This sample shows how the icon template options effect the rendering of built-in SVG templates.</p>
|
|
65
|
+
<a href="examples/SVG%20template%20options.html" target="_blank">Run example</a> |
|
|
66
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/SVG%20template%20options.html" target="_blank">Source code</a>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div class="card">
|
|
71
|
+
<img src="assets/Add%20custom%20SVG%20template%20to%20template%20manager.jpg" style="width:100%">
|
|
72
|
+
<div class="container">
|
|
73
|
+
<h4><b>Add custom SVG template to template manager</b></h4>
|
|
74
|
+
<p>This sample shows how to add more image templates to the SVG template manager.</p>
|
|
75
|
+
<a href="examples/Add%20custom%20SVG%20template%20to%20template%20manager.html" target="_blank">Run example</a> |
|
|
76
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/Add%20custom%20SVG%20template%20to%20template%20manager.html" target="_blank">Source code</a>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div class="card">
|
|
81
|
+
<img src="assets/All%20built-in%20SVG%20templates%20as%20HTML%20markers.jpg" style="width:100%">
|
|
82
|
+
<div class="container">
|
|
83
|
+
<h4><b>All built-in SVG templates as HTML markers</b></h4>
|
|
84
|
+
<p>This sample shows all the built-in SVG templates rendered as HTML markers.</p>
|
|
85
|
+
<a href="examples/All%20built-in%20SVG%20templates%20as%20HTML%20markers.html" target="_blank">Run example</a> |
|
|
86
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/All%20built-in%20SVG%20templates%20as%20HTML%20markers.html" target="_blank">Source code</a>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div class="card">
|
|
91
|
+
<img src="assets/All%20built-in%20SVG%20templates%20as%20symbols.jpg" style="width:100%">
|
|
92
|
+
<div class="container">
|
|
93
|
+
<h4><b>All built-in SVG templates as symbols</b></h4>
|
|
94
|
+
<p>This sample shows all the built-in icon templates rendered on a symbol layer.</p>
|
|
95
|
+
<a href="examples/All%20built-in%20SVG%20templates%20as%20symbols.html" target="_blank">Run example</a> |
|
|
96
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/All%20built-in%20SVG%20templates%20as%20symbols.html" target="_blank">Source code</a>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div class="card">
|
|
101
|
+
<img src="assets/Fill%20polygon%20with%20built-in%20SVG%20template.jpg" style="width:100%">
|
|
102
|
+
<div class="container">
|
|
103
|
+
<h4><b>Fill polygon with built-in SVG template</b></h4>
|
|
104
|
+
<p>This sample shows how to use an SVG template as a fill pattern for a polygon.</p>
|
|
105
|
+
<a href="examples/Fill%20polygon%20with%20built-in%20SVG%20template.html" target="_blank">Run example</a> |
|
|
106
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/Fill%20polygon%20with%20built-in%20SVG%20template.html" target="_blank">Source code</a>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div class="card">
|
|
111
|
+
<img src="assets/HTML%20Marker%20with%20built-in%20SVG%20template.jpg" style="width:100%">
|
|
112
|
+
<div class="container">
|
|
113
|
+
<h4><b>HTML Marker with built-in SVG template</b></h4>
|
|
114
|
+
<p> This sample shows how use SVG templates with an HTML marker, and how to update the marker with a new template. </p>
|
|
115
|
+
<a href="examples/HTML%20Marker%20with%20built-in%20SVG%20template.html" target="_blank">Run example</a> |
|
|
116
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/HTML%20Marker%20with%20built-in%20SVG%20template.html" target="_blank">Source code</a>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div class="card">
|
|
121
|
+
<img src="assets/HTML%20Marker%20with%20Custom%20SVG%20Template.jpg" style="width:100%">
|
|
122
|
+
<div class="container">
|
|
123
|
+
<h4><b>HTML Marker with Custom SVG Template</b></h4>
|
|
124
|
+
<p>This sample shows how to create a custom SVG template and use it with the Html Marker class.</p>
|
|
125
|
+
<a href="examples/HTML%20Marker%20with%20Custom%20SVG%20Template.html" target="_blank">Run example</a> |
|
|
126
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/HTML%20Marker%20with%20Custom%20SVG%20Template.html" target="_blank">Source code</a>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div class="card">
|
|
131
|
+
<img src="assets/Line%20layer%20with%20built-in%20SVG%20template.jpg" style="width:100%">
|
|
132
|
+
<div class="container">
|
|
133
|
+
<h4><b>Line layer with built-in SVG template</b></h4>
|
|
134
|
+
<p>This sample shows how to use a built-in SVG template with a line layer.</p>
|
|
135
|
+
<a href="examples/Line%20layer%20with%20built-in%20SVG%20template.html" target="_blank">Run example</a> |
|
|
136
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/Line%20layer%20with%20built-in%20SVG%20template.html" target="_blank">Source code</a>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<div class="card">
|
|
141
|
+
<img src="assets/Symbol%20layer%20with%20built-in%20SVG%20template.jpg" style="width:100%">
|
|
142
|
+
<div class="container">
|
|
143
|
+
<h4><b>Symbol layer with built-in SVG template</b></h4>
|
|
144
|
+
<p>This sample shows how to use an SVG template as an icon in a symbol layer.</p>
|
|
145
|
+
<a href="examples/Symbol%20layer%20with%20built-in%20SVG%20template.html" target="_blank">Run example</a> |
|
|
146
|
+
<a href="https://github.com/rbrundritt/maplibre-gl-svg/blob/main/examples/Symbol%20layer%20with%20built-in%20SVG%20template.html" target="_blank">Source code</a>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</body>
|
|
151
|
+
</html>
|