mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Change maps source to use Wikimedia maps.
Add link to Wikimedia maps ToS. If there's no data, show the map anyway.
This commit is contained in:
parent
69fb6e77fc
commit
2628f17fae
1 changed files with 22 additions and 24 deletions
|
@ -21,7 +21,7 @@ class ShowOnMap extends Operation {
|
||||||
|
|
||||||
this.name = "Show on map";
|
this.name = "Show on map";
|
||||||
this.module = "Hashing";
|
this.module = "Hashing";
|
||||||
this.description = "Displays co-ordinates on an OpenStreetMap slippy map.<br><br>Co-ordinates will be converted to decimal degrees before being shown on the map.<br><br>Supported formats:<ul><li>Degrees Minutes Seconds (DMS)</li><li>Degrees Decimal Minutes (DDM)</li><li>Decimal Degrees (DD)</li><li>Geohash</li><li>Military Grid Reference System (MGRS)</li><li>Ordnance Survey National Grid (OSNG)</li><li>Universal Transverse Mercator (UTM)</li></ul><br>This operation will not work offline.";
|
this.description = "Displays co-ordinates on a slippy map.<br><br>Co-ordinates will be converted to decimal degrees before being shown on the map.<br><br>Supported formats:<ul><li>Degrees Minutes Seconds (DMS)</li><li>Degrees Decimal Minutes (DDM)</li><li>Decimal Degrees (DD)</li><li>Geohash</li><li>Military Grid Reference System (MGRS)</li><li>Ordnance Survey National Grid (OSNG)</li><li>Universal Transverse Mercator (UTM)</li></ul><br>This operation will not work offline.";
|
||||||
this.infoURL = "";
|
this.infoURL = "";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
|
@ -81,19 +81,21 @@ class ShowOnMap extends Operation {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
async present(data, args) {
|
async present(data, args) {
|
||||||
if (data.replace(/\s+/g, "") !== "") {
|
if (data.replace(/\s+/g, "") === "") {
|
||||||
|
data = "0, 0";
|
||||||
|
}
|
||||||
const zoomLevel = args[0];
|
const zoomLevel = args[0];
|
||||||
const tileUrl = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
const tileUrl = "https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png",
|
||||||
tileAttribution = "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors",
|
tileAttribution = "<a href=\"https://wikimediafoundation.org/wiki/Maps_Terms_of_Use\">Wikimedia maps</a> | © <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors",
|
||||||
leafletUrl = "https://unpkg.com/leaflet@1.4.0/dist/leaflet.js",
|
leafletUrl = "https://unpkg.com/leaflet@1.5.0/dist/leaflet.js",
|
||||||
leafletCssUrl = "https://unpkg.com/leaflet@1.4.0/dist/leaflet.css";
|
leafletCssUrl = "https://unpkg.com/leaflet@1.5.0/dist/leaflet.css";
|
||||||
return `<link rel="stylesheet" href="${leafletCssUrl}" crossorigin=""/>
|
return `<link rel="stylesheet" href="${leafletCssUrl}" crossorigin=""/>
|
||||||
<style>#output-html { white-space: normal; }</style>
|
<style>#output-html { white-space: normal; }</style>
|
||||||
<div id="presentedMap" style="width: 100%; height: 100%;"></div>
|
<div id="presentedMap" style="width: 100%; height: 100%;"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var mapscript = document.createElement('script');
|
var mapscript = document.createElement('script');
|
||||||
document.body.appendChild(mapscript);
|
document.body.appendChild(mapscript);
|
||||||
mapscript.onload = function() {
|
mapscript.onload = function() {
|
||||||
var presentMap = L.map('presentedMap').setView([${data}], ${zoomLevel});
|
var presentMap = L.map('presentedMap').setView([${data}], ${zoomLevel});
|
||||||
L.tileLayer('${tileUrl}', {
|
L.tileLayer('${tileUrl}', {
|
||||||
attribution: '${tileAttribution}'
|
attribution: '${tileAttribution}'
|
||||||
|
@ -102,13 +104,9 @@ class ShowOnMap extends Operation {
|
||||||
L.marker([${data}]).addTo(presentMap)
|
L.marker([${data}]).addTo(presentMap)
|
||||||
.bindPopup('${data}')
|
.bindPopup('${data}')
|
||||||
.openPopup();
|
.openPopup();
|
||||||
};
|
};
|
||||||
mapscript.src = "${leafletUrl}";
|
mapscript.src = "${leafletUrl}";
|
||||||
</script>`;
|
</script>`;
|
||||||
} else {
|
|
||||||
// Don't do anything if there's no input
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue