generated from shgysk8zer0/static-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #379 from kernvalley/patch/update
Update `<leaflet-map>`
- Loading branch information
Showing
11 changed files
with
62 additions
and
80 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
"@aegisjsproject/aegis-md/": "https://unpkg.com/@aegisjsproject/[email protected]/", | ||
"@aegisjsproject/url": "https://unpkg.com/@aegisjsproject/[email protected]/url.mjs", | ||
"@aegisjsproject/url/": "https://unpkg.com/@aegisjsproject/[email protected]/", | ||
"@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/[email protected].14/", | ||
"@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/[email protected].15/", | ||
"@aegisjsproject/state": "https://unpkg.com/@aegisjsproject/[email protected]/state.mjs", | ||
"@aegisjsproject/state/": "https://unpkg.com/@aegisjsproject/[email protected]/", | ||
"@aegisjsproject/router": "https://unpkg.com/@aegisjsproject/[email protected]/router.mjs", | ||
|
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 |
---|---|---|
|
@@ -12,8 +12,8 @@ | |
type: module | ||
defer: true | ||
referrerPolicy: no-referrer | ||
- src: https://unpkg.com/@shgysk8zer0/[email protected].14/leaflet/bundle.min.js | ||
- src: https://unpkg.com/@shgysk8zer0/[email protected].15/leaflet/bundle.min.js | ||
referrerPolicy: no-referrer | ||
crossOrigin: anonymous | ||
integrity: sha384-Wcpoq8RX6zqLoy6E7Q8R972SBG4HBN0E2aJqF1QooAHRk+1Mf3ZiMsPYYZP1/hvK | ||
integrity: sha384-WUuJCItQM/sZRdTS+c7zbGzU70OOUCssPIU4RchSbaxr9joY5B+6eqIIyXhWH8vD | ||
defer: true |
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 |
---|---|---|
|
@@ -17,8 +17,8 @@ | |
- src: /js/index.min.js | ||
referrerPolicy: no-referrer | ||
defer: true | ||
- src: https://unpkg.com/@shgysk8zer0/[email protected].14/leaflet/bundle.min.js | ||
- src: https://unpkg.com/@shgysk8zer0/[email protected].15/leaflet/bundle.min.js | ||
referrerPolicy: no-referrer | ||
crossOrigin: anonymous | ||
integrity: sha384-Wcpoq8RX6zqLoy6E7Q8R972SBG4HBN0E2aJqF1QooAHRk+1Mf3ZiMsPYYZP1/hvK | ||
integrity: sha384-WUuJCItQM/sZRdTS+c7zbGzU70OOUCssPIU4RchSbaxr9joY5B+6eqIIyXhWH8vD | ||
defer: true |
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 |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
<script type="application/javascript" defer="" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-S6IiMVrhK2h8SpNcu3w1ybvXAcAPLcN6DC8dy35bqDEcqIt4wP5zBGTYd96qtGRi" src="https://unpkg.com/@shgysk8zer0/[email protected]/browser.min.js"></script> | ||
<script type="application/javascript" defer="" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-55L/wO9o0uIVTeubRIDQB4bewfNqyxrj4OXuxlW24NMEk+ioZwMHVw/tFV78mM+k" src="https://unpkg.com/@shgysk8zer0/[email protected]/harden.js"></script> | ||
<script src="/js/embed.js" referrerpolicy="no-referrer" defer=""></script> | ||
<script type="application/javascript" defer="" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-Wcpoq8RX6zqLoy6E7Q8R972SBG4HBN0E2aJqF1QooAHRk+1Mf3ZiMsPYYZP1/hvK" src="https://unpkg.com/@shgysk8zer0/[email protected].14/leaflet/bundle.min.js"></script> | ||
<script type="application/javascript" defer="" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-WUuJCItQM/sZRdTS+c7zbGzU70OOUCssPIU4RchSbaxr9joY5B+6eqIIyXhWH8vD" src="https://unpkg.com/@shgysk8zer0/[email protected].15/leaflet/bundle.min.js"></script> | ||
<link rel="stylesheet" href="/css/embed.css" referrerpolicy="no-referrer" media="all" /> | ||
</head> | ||
<body></body> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ import { getCustomElement } from '@shgysk8zer0/kazoo/custom-elements.js'; | |
import { getGooglePolicy, getDefaultPolicy } from '@shgysk8zer0/kazoo/trust-policies.js'; | ||
import { ready, loaded, toggleClass, on, attr } from '@shgysk8zer0/kazoo/dom.js'; | ||
import { importGa, externalHandler, mailtoHandler, telHandler } from '@shgysk8zer0/kazoo/google-analytics.js'; | ||
import { decodeGeohash, parseGeoURI } from 'https://unpkg.com/@shgysk8zer0/[email protected]/geoutils.js'; | ||
import { consumeHandler } from './functions.js'; | ||
import { addEventsToMap } from './events.js'; | ||
import { GA } from './consts.js'; | ||
|
@@ -56,67 +55,26 @@ try { | |
} | ||
|
||
if (location.search.includes('geo')) { | ||
const params = new URLSearchParams(location.search); | ||
|
||
if (params.has('geo')) { | ||
try { | ||
const { | ||
coords: { latitude = NaN, longitude = NaN } = {}, | ||
params: { zoom = 16, query = 'Marked Location' } = {}, | ||
} = parseGeoURI(params.get('geo')); | ||
|
||
if (! (Number.isNaN(latitude) || Number.isNaN(longitude))) { | ||
Promise.all([ | ||
customElements.whenDefined('leaflet-marker'), | ||
customElements.whenDefined('leaflet-map'), | ||
]).then(([LeafletMarker]) => { | ||
const popup = document.createElement('div'); | ||
const label = document.createElement('b'); | ||
const coords = document.createElement('pre'); | ||
const map = document.querySelector('leaflet-map'); | ||
const url = new URL(location.pathname, location.origin); | ||
|
||
label.textContent = query; | ||
coords.textContent = `${latitude.toFixed(5)}, ${longitude.toFixed(5)}`; | ||
popup.append(label, document.createElement('br'), coords); | ||
const marker = new LeafletMarker({ latitude, longitude, popup, open: false }); | ||
marker.id = 'marked-geo-location'; | ||
map.append(marker); | ||
map.zoom = zoom; | ||
marker.open = true; | ||
url.hash = `#${latitude},${longitude},${zoom}`; | ||
history.replaceState(history.state, '', url.href); | ||
}); | ||
} | ||
} catch(err) { | ||
console.error(err); | ||
} | ||
} else if (params.has('geohash')) { | ||
try { | ||
const { latitude = NaN, longitude = NaN } = decodeGeohash(params.get('geohash')); | ||
|
||
if (! (Number.isNaN(latitude) || Number.isNaN(longitude))) { | ||
const url = new URL(location.pathname, location.origin); | ||
url.hash = `#${latitude},${longitude}`; | ||
history.replaceState(history.state, '', url.href); | ||
} | ||
} catch(err) { | ||
console.error(err); | ||
customElements.whenDefined('leaflet-map').then(() => { | ||
const params = new URLSearchParams(location.search); | ||
const map = document.getElementById('map'); | ||
const url = new URL(location.href); | ||
|
||
if (params.has('geo')) { | ||
map.geo = params.get('geo'); | ||
url.searchParams.delete('geo'); | ||
history.replaceState(history.state, '', url.href); | ||
} else if (params.has('geohash')) { | ||
map.geohash = params.get('geohash'); | ||
url.searchParams.delete('geohash'); | ||
history.replaceState(history.state, '', url.href); | ||
} | ||
} | ||
}); | ||
//0123456789bcdefghjkmnpqrstuvwxyz 32-bit alphabet | ||
} else if (location.hash.length > 2 && /^#[0-9b-hjk-np-z]{2,12}$/.test(location.hash)) { | ||
try { | ||
const { latitude = NaN, longitude = NaN } = decodeGeohash(location.hash.substring(1)); | ||
|
||
if (! (Number.isNaN(latitude) || Number.isNaN(longitude))) { | ||
const url = new URL(location.pathname, location.origin); | ||
url.hash = `#${latitude},${longitude}`; | ||
history.replaceState(history.state, '', url.href); | ||
} | ||
} catch(err) { | ||
console.error(err); | ||
} | ||
customElements.whenDefined('leaflet-map').then(() => { | ||
document.getElementById('map').geohash = location.hash.substring(1); | ||
}); | ||
} | ||
|
||
ready().then(async () => { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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