Simple tool to get a that one can copy-paste into a wikimedia page, from a GeoJSON feature collection.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.3 KiB

<!doctype html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@turf/turf@5/turf.min.js"></script>
<style>
body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
#left {
float: left;
width: 50%;
height: 100%;
}
#geojson {
height: 400px;
width: 90%;
}
#right {
width: 48%;
}
</style>
</head>
<body>
<div id="container">
<div id="left">
<textarea id="geojson">
</textarea> <br />
<button id="generateMapframe">Create Mapframe</button>
</div>
<pre id="right">
</pre>
</div>
<script>
document.getElementById('generateMapframe').addEventListener('click', () => {
let fc;
try {
fc = JSON.parse(document.getElementById('geojson').value);
} catch (e) {
alert('Invalid GeoJSON');
return;
}
window.foo = fc;
const center = turf.center(fc);
const lon = center.geometry.coordinates[0];
const lat = center.geometry.coordinates[1];
const mapframe = `
&lt;mapframe latitude="${lat}" longitude="${lon}" zoom="8">
${JSON.stringify(fc, null, 2)}
&lt;/mapframe>
`;
document.getElementById('right').innerHTML = mapframe;
});
</script>
</body>
</html>