Stub kml for our game with McTavish's

pull/1/head
Daniel Asher Resnick 4 years ago
parent 6acbb43065
commit 0c3588fe54
  1. 27
      index.html
  2. 10
      ours.kml

@ -18,6 +18,7 @@
<script>
var chinagreen;
var shadowrun;
var ours;
var map = L.map('map').setView([47.63,-122.33], 10);
var gl = L.mapboxGL({
attribution: "\u003ca href=\"https://www.maptiler.com/copyright/\" target=\"_blank\"\u003e\u0026copy; MapTiler\u003c/a\u003e \u003ca href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\"\u003e\u0026copy; OpenStreetMap contributors\u003c/a\u003e",
@ -41,6 +42,15 @@
chinagreen = new L.KML(kml);
map.addLayer(chinagreen);
});
fetch('ours.kml')
.then(res => res.text())
.then(kmltext => {
// Create new kml overlay
const parser = new DOMParser();
const kml = parser.parseFromString(kmltext, 'text/xml');
ours = new L.KML(kml);
map.addLayer(ours);
});
var chinagreenswitcher = L.control({position: 'topleft'});
chinagreenswitcher.onAdd = function (map) {
@ -62,6 +72,16 @@
shadowrunswitcher.addTo(map);
document.getElementById ("shadowrunswitcher").addEventListener ("click", toggleShadowrun, false);
oursswitcher.onAdd = function (map) {
var div = L.DomUtil.create('div', 'ours');
div.innerHTML = '<form><input id="oursswitcher" type="checkbox" checked />Toggle District Info</form>';
return div;
};
oursswitcher.addTo(map);
document.getElementById ("oursswitcher").addEventListener ("click", toggleOurs, false);
function toggleChinaGreen() {
if(this.checked){
map.addLayer(chinagreen);
@ -76,6 +96,13 @@
map.removeLayer(shadowrun);
}
}
function toggleOurs() {
if(this.checked){
map.addLayer(ours);
}else{
map.removeLayer(ours);
}
}
</script>
</body>
</html>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Placemark>
<name>McTavish's</name>
<description></description>
<Point>
<coordinates>-122.07850635051729,47.67988678685347,0</coordinates>
</Point>
</Placemark>
</kml>
Loading…
Cancel
Save