Update to its current state.
This commit is contained in:
parent
8a1f42c6be
commit
6ae9200c06
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
80
index.html
80
index.html
@ -28,18 +28,73 @@
|
|||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<pre id="info"></pre>
|
<pre id="info"></pre>
|
||||||
<script>
|
<script>
|
||||||
|
// const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
|
var api_key = "rYNCGwdgATyHCjyDil7t";
|
||||||
|
var serverURL = "http://homeplate.close-air.support:8888/";
|
||||||
var map = new maplibregl.Map({
|
var map = new maplibregl.Map({
|
||||||
container: 'map',
|
center: [42, 42],
|
||||||
style: 'https://api.maptiler.com/maps/topo-v2/style.json?key=<replace-me>',
|
container: "map",
|
||||||
center: [42, 42],
|
style: "https://api.maptiler.com/maps/topo-v2/style.json?key="+api_key,
|
||||||
zoom: 7
|
zoom: 7
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('load', function () {
|
map.on("load", () => {
|
||||||
|
|
||||||
|
myData = fetchData(serverURL);
|
||||||
|
for (chip in myData)
|
||||||
|
{
|
||||||
|
//latest.push(myData[chip].UnitName);
|
||||||
|
let UnitImage = myData[chip].UnitName+"-img";
|
||||||
|
let UnitSource = myData[chip].UnitName+"-src";
|
||||||
|
let UnitPoint = myData[chip].UnitName+"-point";
|
||||||
|
let UnitLong = myData[chip].Longitude;
|
||||||
|
let UnitLati = myData[chip].Latitude;
|
||||||
|
let UnitCoalition = myData[chip].Coalition;
|
||||||
|
|
||||||
|
map.loadImage(
|
||||||
|
"/symbols/"+UnitCoalition+"/plane.png",
|
||||||
|
(error, image) => {
|
||||||
|
if (error) throw error;
|
||||||
|
map.addImage(UnitImage, image);
|
||||||
|
map.addSource(UnitSource, { "type": 'geojson', 'data': { 'type': 'FeatureCollection', 'features': [{ 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [UnitLong, UnitLati] } }] } } );
|
||||||
|
map.addLayer({
|
||||||
|
'id': UnitPoint,
|
||||||
|
'type': 'symbol',
|
||||||
|
'source': UnitSource,
|
||||||
|
'layout': {
|
||||||
|
'icon-image': UnitImage,
|
||||||
|
'icon-size': 0.25
|
||||||
|
}
|
||||||
|
}); // map.addLayer()
|
||||||
|
}
|
||||||
|
); // map.loadImage()
|
||||||
|
|
||||||
|
};// End for() loop
|
||||||
|
|
||||||
|
// Deletion
|
||||||
|
// await sleep(10000);
|
||||||
|
// for (chip in myData)
|
||||||
|
// {
|
||||||
|
// //latest.push(myData[chip].UnitName);
|
||||||
|
// let UnitImage = myData[chip].UnitName+"-img";
|
||||||
|
// let UnitSource = myData[chip].UnitName+"-src";
|
||||||
|
// let UnitPoint = myData[chip].UnitName+"-point";
|
||||||
|
|
||||||
|
// if (map.hasImage(UnitImage)) map.removeImage(UnitImage);
|
||||||
|
// if (map.getSource(UnitSource)) map.removeSource(UnitSource);
|
||||||
|
// if (map.getLayer(UnitPoint)) map.removeLayer(UnitPoint);
|
||||||
|
// };
|
||||||
|
|
||||||
|
}); // End map.on()
|
||||||
|
|
||||||
|
|
||||||
});
|
// function wait(ms){
|
||||||
|
// var start = new Date().getTime();
|
||||||
|
// var end = start;
|
||||||
|
// while(end < start + ms) {
|
||||||
|
// end = new Date().getTime();
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
|
||||||
function MGRSString (Lat, Long) {
|
function MGRSString (Lat, Long) {
|
||||||
//if (Lat < -80) return 'Too far South' ; if (Lat > 84) return 'Too far North' ;
|
//if (Lat < -80) return 'Too far South' ; if (Lat > 84) return 'Too far North' ;
|
||||||
@ -82,6 +137,17 @@
|
|||||||
document.getElementById('info').innerHTML = MGRSString(coordinate.lat, coordinate.lng);
|
document.getElementById('info').innerHTML = MGRSString(coordinate.lat, coordinate.lng);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function fetchData(url)
|
||||||
|
{
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
var retval
|
||||||
|
|
||||||
|
xhr.open("GET", url, false);
|
||||||
|
xhr.send();
|
||||||
|
|
||||||
|
return JSON.parse(xhr.responseText)
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user