diff options
author | Ruben Rodriguez <ruben@trisquel.info> | 2022-09-08 20:18:54 -0400 |
---|---|---|
committer | Ruben Rodriguez <ruben@trisquel.info> | 2022-09-08 20:18:54 -0400 |
commit | 5da28b0f8771834ae208d61431d632875e9f8e7d (patch) | |
tree | 688ecaff26197bad8abde617b4947b11d617309e /data/extensions/{b7f9d2cd-d772-4302-8c3f-eb941af36f76}/assets/javascripts/helpers/google-maps.js | |
parent | 4a87716686104266a9cccc2d83cc249e312f3673 (diff) |
Updated extensions:
* Upgraded Privacy Redirect to 1.1.49 and configured to use the 10 most reliable invidious instances
* Removed ViewTube
* Added torproxy@icecat.gnu based on 'Proxy toggle' extension
* Added jShelter 0.11.1
* Upgraded LibreJS to 7.21.0
* Upgraded HTTPS Everywhere to 2021.7.13
* Upgraded SubmitMe to 1.9
Diffstat (limited to 'data/extensions/{b7f9d2cd-d772-4302-8c3f-eb941af36f76}/assets/javascripts/helpers/google-maps.js')
-rw-r--r-- | data/extensions/{b7f9d2cd-d772-4302-8c3f-eb941af36f76}/assets/javascripts/helpers/google-maps.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/data/extensions/{b7f9d2cd-d772-4302-8c3f-eb941af36f76}/assets/javascripts/helpers/google-maps.js b/data/extensions/{b7f9d2cd-d772-4302-8c3f-eb941af36f76}/assets/javascripts/helpers/google-maps.js new file mode 100644 index 0000000..2ba924b --- /dev/null +++ b/data/extensions/{b7f9d2cd-d772-4302-8c3f-eb941af36f76}/assets/javascripts/helpers/google-maps.js @@ -0,0 +1,52 @@ +const targets = /https?:\/\/(((www|maps)\.)?(google\.).*(\/maps)|maps\.(google\.).*)/; +const redirects = ["https://openstreetmap.org"]; +const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/; +const dataLatLngRegex = /(!3d|!4d)(-?[0-9]{1,10}.[0-9]{1,10})/g; +const placeRegex = /\/place\/(.*)\//; +const travelModes = { + driving: "fossgis_osrm_car", + walking: "fossgis_osrm_foot", + bicycling: "fossgis_osrm_bike", + transit: "fossgis_osrm_car", // not implemented on OSM, default to car. +}; +const layers = { + none: "S", + transit: "T", + traffic: "S", // not implemented on OSM, default to standard. + bicycling: "C", +}; +function addressToLatLng(address, callback) { + const xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = () => { + if (xmlhttp.readyState === XMLHttpRequest.DONE) { + if (xmlhttp.status === 200) { + const json = JSON.parse(xmlhttp.responseText)[0]; + if (json) { + callback( + `${json.lat}%2C${json.lon}`, + `${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}` + ); + } + } else { + console.info("Error: Status is " + xmlhttp.status); + } + } + }; + xmlhttp.open( + "GET", + `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, + false + ); + xmlhttp.send(); +} + +export default { + targets, + redirects, + mapCentreRegex, + dataLatLngRegex, + placeRegex, + travelModes, + layers, + addressToLatLng, +}; |