|
58 | 58 | * as described here: https://docs.protomaps.com/pmtiles/leaflet, and as |
59 | 59 | * exemplified below. |
60 | 60 | */ |
| 61 | +const sheet = new protomapsL.Sheet(` |
| 62 | +<html> |
| 63 | + <body> |
| 64 | + <svg id="icon_0" width="99px" height="97px" xmlns="http://www.w3.org/2000/svg"> |
| 65 | + <image href="data:image/svg+xml;base64,PHN2ZyBpZD0iaWNvbl82NCIgd2lkdGg9IjE2cHgiIGhlaWdodD0iMTZweCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgICAgPGltYWdlIGhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBQkFBQUFBUUNBWUFBQUFmOC85aEFBQUFDWEJJV1hNQUFBN0VBQUFPeEFHVkt3NGJBQUFBMlVsRVFWUjRuTldQTVdvQ1lSQ0Z2MElDZ2xZaFZnRUwzZmNyZGlsczBteVJUdkFLa2xaSXdKM2ZpTjE2aGhoeUFCRkVjZ2J2WUtFbmtCUkpiNWtFSlRheXNNdFd5WVBYRFBPOW1RZC9YcjVHSlRkc1Rhb21wdm12TzBZbVB1T1FRcjRQeE5yRXR3L29wQzdITFM1TVRFd3NEdmFPdHdOOERCRGIwenh5eklkMWJoSkQraTFLWHN4T1lJSjN2a0dZM2ozZ1BnRmVqUnRjWnVvK2ROeWVCM2l4Skt0TXZQeUNtMGc4bS9neXNYOXlsRlBoT0tUZ3hZYzVYZ2ZYRkkrVnhKMkpkeE85MUlDQmFFZU83dm44b2M2VkQzak1YT1AvNkFmS0Ywd3dXeU9Oc3dBQUFBQkpSVTVFcmtKZ2dnPT0iIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIvPgogICAgPC9zdmc+" width="99" height="97" /> |
| 66 | + </svg> |
| 67 | + </body> |
| 68 | +</html> |
| 69 | +`); |
61 | 70 |
|
62 | 71 | class SpearfishSymbolizer { |
63 | 72 | constructor(options) { |
@@ -88,87 +97,91 @@ class SpearfishSymbolizer { |
88 | 97 |
|
89 | 98 | */ |
90 | 99 | const pmtilesRules = new Map(); |
91 | | -pmtilesRules.set( |
92 | | - 'https://data.source.coop/protomaps/openstreetmap/tiles/v3.pmtiles', |
93 | | - { theme: { theme: 'light' } } |
94 | | -); |
95 | | -pmtilesRules.set( |
96 | | - 'https://data.source.coop/protomaps/openstreetmap/tiles/v3.pmtiles?theme=light', |
97 | | - { theme: { theme: 'light' } } |
98 | | -); |
99 | | -pmtilesRules.set( |
100 | | - 'https://data.source.coop/protomaps/openstreetmap/tiles/v3.pmtiles?theme=dark', |
101 | | - { theme: { theme: 'dark' } } |
102 | | -); |
103 | | -pmtilesRules.set( |
104 | | - 'https://api.protomaps.com/tiles/v3/{bing}/{bong}/{bang}.mvt?key=41392fb7515533a5', |
105 | | - { theme: { theme: 'light' } } |
106 | | -); |
107 | | -pmtilesRules.set( |
108 | | - 'http://localhost:8080/geoserver/gwc/service/wmts/rest/spearfish/OSMTILE/{foo}/{baz}/{bar}?format=application/vnd.mapbox-vector-tile', |
109 | | - { |
110 | | - rules: { |
111 | | - PAINT_RULES: [ |
112 | | - { |
113 | | - dataLayer: 'streams', |
114 | | - symbolizer: new protomapsL.LineSymbolizer({ |
115 | | - color: 'steelblue', |
116 | | - width: 2 |
117 | | - }) |
118 | | - }, |
119 | | - { |
120 | | - dataLayer: 'roads', |
121 | | - symbolizer: new protomapsL.LineSymbolizer({ |
122 | | - color: 'maroon', |
123 | | - width: 2 |
124 | | - }) |
125 | | - }, |
126 | | - { |
127 | | - dataLayer: 'restricted', |
128 | | - symbolizer: new protomapsL.PolygonSymbolizer({ |
129 | | - fill: 'red', |
130 | | - opacity: 0.5 |
131 | | - }) |
132 | | - }, |
133 | | - { |
134 | | - dataLayer: 'restricted', |
135 | | - symbolizer: new protomapsL.LineSymbolizer({ |
136 | | - color: 'red', |
137 | | - width: 2 |
138 | | - }) |
139 | | - }, |
140 | | - { |
141 | | - dataLayer: 'archsites', |
142 | | - symbolizer: new SpearfishSymbolizer({ |
143 | | - color: 'red', |
144 | | - shape: 'square' |
145 | | - }) |
146 | | - }, |
147 | | - { |
148 | | - dataLayer: 'bugsites', |
149 | | - symbolizer: new SpearfishSymbolizer({ |
150 | | - color: 'black', |
151 | | - shape: 'circle' |
152 | | - }) |
153 | | - } |
154 | | - ], |
155 | | - LABEL_RULES: [ |
156 | | - { |
157 | | - dataLayer: 'archsites', |
158 | | - symbolizer: new protomapsL.CenteredTextSymbolizer({ |
159 | | - labelProps: ['str1'], |
160 | | - fill: 'white', |
161 | | - width: 2, |
162 | | - stroke: 'black', |
163 | | - font: '600 16px sans-serif' |
164 | | - }), |
165 | | - // note that filter is a property of a rule, not an option to a symbolizer |
166 | | - filter: (z, f) => { |
167 | | - return f.props.str1.trim().toLowerCase() !== 'no name'; |
| 100 | +const pmtilesRulesReady = sheet.load().then(() => { |
| 101 | + pmtilesRules.set( |
| 102 | + 'https://data.source.coop/protomaps/openstreetmap/tiles/v3.pmtiles', |
| 103 | + { theme: { theme: 'light' } } |
| 104 | + ); |
| 105 | + pmtilesRules.set( |
| 106 | + 'https://data.source.coop/protomaps/openstreetmap/tiles/v3.pmtiles?theme=light', |
| 107 | + { theme: { theme: 'light' } } |
| 108 | + ); |
| 109 | + pmtilesRules.set( |
| 110 | + 'https://data.source.coop/protomaps/openstreetmap/tiles/v3.pmtiles?theme=dark', |
| 111 | + { theme: { theme: 'dark' } } |
| 112 | + ); |
| 113 | + pmtilesRules.set( |
| 114 | + 'https://api.protomaps.com/tiles/v3/{bing}/{bong}/{bang}.mvt?key=41392fb7515533a5', |
| 115 | + { theme: { theme: 'light' } } |
| 116 | + ); |
| 117 | + pmtilesRules.set( |
| 118 | + 'http://localhost:8080/geoserver/gwc/service/wmts/rest/spearfish/OSMTILE/{foo}/{baz}/{bar}?format=application/vnd.mapbox-vector-tile', |
| 119 | + { |
| 120 | + rules: { |
| 121 | + PAINT_RULES: [ |
| 122 | + { |
| 123 | + dataLayer: 'streams', |
| 124 | + symbolizer: new protomapsL.LineSymbolizer({ |
| 125 | + color: 'steelblue', |
| 126 | + width: 2 |
| 127 | + }) |
| 128 | + }, |
| 129 | + { |
| 130 | + dataLayer: 'roads', |
| 131 | + symbolizer: new protomapsL.LineSymbolizer({ |
| 132 | + color: 'maroon', |
| 133 | + width: 2 |
| 134 | + }) |
| 135 | + }, |
| 136 | + { |
| 137 | + dataLayer: 'restricted', |
| 138 | + symbolizer: new protomapsL.PolygonSymbolizer({ |
| 139 | + fill: 'red', |
| 140 | + opacity: 0.5 |
| 141 | + }) |
| 142 | + }, |
| 143 | + { |
| 144 | + dataLayer: 'restricted', |
| 145 | + symbolizer: new protomapsL.LineSymbolizer({ |
| 146 | + color: 'red', |
| 147 | + width: 2 |
| 148 | + }) |
| 149 | + }, |
| 150 | + { |
| 151 | + dataLayer: 'archsites', |
| 152 | + symbolizer: new SpearfishSymbolizer({ |
| 153 | + color: 'red', |
| 154 | + shape: 'square' |
| 155 | + }) |
| 156 | + }, |
| 157 | + { |
| 158 | + dataLayer: 'bugsites', |
| 159 | + symbolizer: new SpearfishSymbolizer({ |
| 160 | + color: 'black', |
| 161 | + shape: 'circle' |
| 162 | + }) |
168 | 163 | } |
169 | | - } |
170 | | - ] |
| 164 | + ], |
| 165 | + LABEL_RULES: [ |
| 166 | + { |
| 167 | + dataLayer: 'archsites', |
| 168 | + symbolizer: new protomapsL.CenteredTextSymbolizer({ |
| 169 | + labelProps: ['str1'], |
| 170 | + fill: 'white', |
| 171 | + width: 2, |
| 172 | + stroke: 'black', |
| 173 | + font: '600 16px sans-serif' |
| 174 | + }), |
| 175 | + // note that filter is a property of a rule, not an option to a symbolizer |
| 176 | + filter: (z, f) => { |
| 177 | + return f.props.str1.trim().toLowerCase() !== 'no name'; |
| 178 | + } |
| 179 | + } |
| 180 | + ] |
| 181 | + } |
171 | 182 | } |
172 | | - } |
173 | | -); |
174 | | -export { pmtilesRules }; |
| 183 | + ); |
| 184 | + return pmtilesRules; |
| 185 | +}); |
| 186 | + |
| 187 | +export { pmtilesRules, pmtilesRulesReady }; |
0 commit comments