|
117 | 117 | </head> |
118 | 118 | <body> |
119 | 119 |
|
120 | | - <mapml-viewer projection="CBMTILE" controls controlslist="geolocation search" zoom="16" lat="45.406314" lon="-75.6883335"> |
| 120 | + <mapml-viewer lang="en" projection="CBMTILE" controls controlslist="geolocation search" zoom="16" lat="45.406314" lon="-75.6883335"> |
121 | 121 | <map-layer label="Canada Base Map - Transportation" checked> |
122 | 122 | <map-link rel="suggestions" tref="https://geogratis.gc.ca/services/geoname/en/geonames.json?q={searchTerms}*&num=20"></map-link> |
123 | 123 | <map-link rel="search" tref="https://geogratis.gc.ca/services/geoname/en/geonames.json?q={searchTerms}&num=20"></map-link> |
|
150 | 150 | </map-extent> |
151 | 151 | </map-layer> |
152 | 152 | </mapml-viewer> |
153 | | - <map is="web-map" projection="OSMTILE" zoom="14" lat="45.406314" lon="-75.6883335" controls controlslist="geolocation search"> |
| 153 | + <map lang="fr" is="web-map" projection="OSMTILE" zoom="14" lat="45.406314" lon="-75.6883335" controls controlslist="geolocation search"> |
154 | 154 | <map-layer data-testid="osm-layer" label="OpenStreetMap" checked > |
155 | 155 |
|
156 | 156 | <map-link rel="license" title="© OpenStreetMap contributors CC BY-SA" href="https://www.openstreetmap.org/copyright"></map-link> |
157 | 157 | <!-- Register your own geonames.org account at https://www.geonames.org/login |
158 | 158 | and enable web services at https://www.geonames.org/manageaccount |
159 | | - then replace username=demo with your username --> |
160 | | - <map-link rel="search" tref="https://secure.geonames.org/searchJSON?q={searchTerms}&maxRows=25&inclBbox=true&username=demo"></map-link> |
161 | | - <map-link rel="suggestions" tref="https://secure.geonames.org/searchJSON?name_startsWith={searchTerms}&maxRows=25&inclBbox=true&orderby=relevance&username=demo"></map-link> |
| 159 | + then replace username=demo with your username |
| 160 | + <map-link rel="search" tref="https://secure.geonames.org/searchJSON?q={searchTerms}&maxRows=25&inclBbox=true&username=prushforth"></map-link> |
| 161 | + <map-link rel="suggestions" tref="https://secure.geonames.org/searchJSON?name_startsWith={searchTerms}&maxRows=25&inclBbox=true&orderby=relevance&username=prushforth"></map-link> |
| 162 | + --> |
| 163 | + <!-- default search handler uses GeoJSON responses that have a quasi-standard 'schema' --> |
| 164 | + <map-link rel="suggestions" tref="https://photon.komoot.io/api?q={searchTerms}"></map-link> |
| 165 | + <map-link rel="search" tref="https://photon.komoot.io/api?q={searchTerms}"></map-link> |
162 | 166 | <map-extent units="OSMTILE" checked="checked"> |
163 | 167 | <map-input name="z" type="zoom" value="18" min="0" max="18"></map-input> |
164 | 168 | <map-input name="x" type="location" units="tilematrix" axis="column" min="0" max="262144"></map-input> |
|
225 | 229 | }); |
226 | 230 |
|
227 | 231 | // --- geonames.org custom handler for the <map is="web-map"> element --- |
228 | | - const webMap = document.querySelector('map[is=web-map]'); |
| 232 | + // const webMap = document.querySelector('map[is=web-map]'); |
229 | 233 |
|
230 | | - function renderGeonamesOrgResults(container, geonames, map) { |
231 | | - container.innerHTML = ''; |
232 | | - for (const item of geonames) { |
233 | | - const btn = document.createElement('button'); |
234 | | - btn.className = 'mapml-search-result'; |
235 | | - btn.setAttribute('type', 'button'); |
236 | | - btn.textContent = item.name |
237 | | - + (item.adminName1 ? ', ' + item.adminName1 : '') |
238 | | - + (item.countryName ? ', ' + item.countryName : ''); |
239 | | - btn.addEventListener('click', () => { |
240 | | - if (item.bbox) { |
241 | | - map.fitBounds([ |
242 | | - [item.bbox.south, item.bbox.west], |
243 | | - [item.bbox.north, item.bbox.east] |
244 | | - ]); |
245 | | - } else { |
246 | | - map.setView([parseFloat(item.lat), parseFloat(item.lng)], 10); |
247 | | - } |
248 | | - map._container |
249 | | - .querySelector('.mapml-search-panel') |
250 | | - .classList.remove('mapml-search-panel-open'); |
251 | | - }); |
252 | | - container.appendChild(btn); |
253 | | - } |
254 | | - } |
| 234 | + // function renderGeonamesOrgResults(container, geonames, map) { |
| 235 | + // container.innerHTML = ''; |
| 236 | + // for (const item of geonames) { |
| 237 | + // const btn = document.createElement('button'); |
| 238 | + // btn.className = 'mapml-search-result'; |
| 239 | + // btn.setAttribute('type', 'button'); |
| 240 | + // btn.textContent = item.name |
| 241 | + // + (item.adminName1 ? ', ' + item.adminName1 : '') |
| 242 | + // + (item.countryName ? ', ' + item.countryName : ''); |
| 243 | + // btn.addEventListener('click', () => { |
| 244 | + // if (item.bbox) { |
| 245 | + // map.fitBounds([ |
| 246 | + // [item.bbox.south, item.bbox.west], |
| 247 | + // [item.bbox.north, item.bbox.east] |
| 248 | + // ]); |
| 249 | + // } else { |
| 250 | + // map.setView([parseFloat(item.lat), parseFloat(item.lng)], 10); |
| 251 | + // } |
| 252 | + // map._container |
| 253 | + // .querySelector('.mapml-search-panel') |
| 254 | + // .classList.remove('mapml-search-panel-open'); |
| 255 | + // }); |
| 256 | + // container.appendChild(btn); |
| 257 | + // } |
| 258 | + // } |
255 | 259 |
|
256 | | - webMap.addEventListener('mapsuggestions', (e) => { |
257 | | - e.preventDefault(); |
258 | | - const container = webMap._map._container.querySelector('.mapml-search-results'); |
259 | | - const allGeonames = e.detail.responses.flatMap(r => (r.data && r.data.geonames) || []); |
260 | | - renderGeonamesOrgResults(container, allGeonames, webMap._map); |
261 | | - }); |
| 260 | + // webMap.addEventListener('mapsuggestions', (e) => { |
| 261 | + // e.preventDefault(); |
| 262 | + // const container = webMap._map._container.querySelector('.mapml-search-results'); |
| 263 | + // const allGeonames = e.detail.responses.flatMap(r => (r.data && r.data.geonames) || []); |
| 264 | + // renderGeonamesOrgResults(container, allGeonames, webMap._map); |
| 265 | + // }); |
262 | 266 |
|
263 | | - webMap.addEventListener('mapsearch', (e) => { |
264 | | - e.preventDefault(); |
265 | | - const container = webMap._map._container.querySelector('.mapml-search-results'); |
266 | | - const allGeonames = e.detail.responses.flatMap(r => (r.data && r.data.geonames) || []); |
267 | | - renderGeonamesOrgResults(container, allGeonames, webMap._map); |
268 | | - }); |
| 267 | + // webMap.addEventListener('mapsearch', (e) => { |
| 268 | + // e.preventDefault(); |
| 269 | + // const container = webMap._map._container.querySelector('.mapml-search-results'); |
| 270 | + // const allGeonames = e.detail.responses.flatMap(r => (r.data && r.data.geonames) || []); |
| 271 | + // renderGeonamesOrgResults(container, allGeonames, webMap._map); |
| 272 | + // }); |
269 | 273 | }); |
270 | 274 | </script> |
271 | 275 | </body> |
|
0 commit comments