iwa-panda2

Manage Weather Data by International Weather Agency (Version 2)
Log | Files | Refs | README

map.js (2128B)


      1 /*$(document).ready(function(){
      2     $(".marker-dutch-harbor").hover(function(){
      3         $(".dutch-harbor-txt").toggle();
      4     });
      5 });
      6 
      7 $(document).ready(function(){
      8     $(".marker-etreillers").hover(function(){
      9         $(".etreillers-txt").toggle();
     10     });
     11 });
     12 
     13 $(document).ready(function(){
     14     $(".marker-inuvik").hover(function(){
     15         $(".inuvik-txt").toggle();
     16     });
     17 });
     18 
     19 $(document).ready(function(){
     20     $(".marker-ko-samui").hover(function(){
     21         $(".ko-samui-txt").toggle();
     22     });
     23 });
     24 
     25 $(document).ready(function(){
     26     $(".marker-kufstein").hover(function(){
     27         $(".kufstein-txt").toggle();
     28     });
     29 });
     30 
     31 $(document).ready(function(){
     32     $(".marker-nurburg").hover(function(){
     33         $(".nurburg-txt").toggle();
     34     });
     35 });
     36 
     37 $(document).ready(function(){
     38     $(".marker-oost-vlieland").hover(function(){
     39         $(".oost-vlieland-txt").toggle();
     40     });
     41 });
     42 
     43 $(document).ready(function(){
     44     $(".marker-sapporo").hover(function(){
     45         $(".sapporo-txt").toggle();
     46     });
     47 });
     48 
     49 $(document).ready(function(){
     50     $(".marker-taipai").hover(function(){
     51         $(".taipai-txt").toggle();
     52     });
     53 });
     54 
     55 $(document).ready(function(){
     56     $(".marker-woolgoolga").hover(function(){
     57         $(".woolgoolga-txt").toggle();
     58     });
     59 });*/
     60 
     61 
     62 var map = L.map('map').setView([51.505, -0.09], 1);
     63 
     64 L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
     65     attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
     66 }).addTo(map);
     67 
     68 const zooToken = ':3jvl7yb5sRr80s6lTdeOyxV9VTQZkCPRp7bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk';
     69 
     70 /*
     71 windchill	-1.48
     72 location	"Dutch Harbor"
     73 country	"United States"
     74 */
     75 
     76 fetch(`http://localhost:8080/api/${zooToken}`)
     77     .then(response => response.json())
     78     .then(data => {
     79         for (let { windchill: windchill, location: city, country } of data) {
     80             fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${city},${country}`)
     81                 .then(res => res.json())
     82                 .then(res => L.marker([ res[0].lat, res[0].lon ]).addTo(map).bindPopup(`${city}, ${country}: ${windchill} &deg;C`))
     83         }
     84     });