// get your key from app.tomorrow.io/development/keys
const API_KEY = ‘fPo5xUf7M7JzNmbtwLQlGaamJ4MHiR7B’;

// pick the field (like temperature, precipitationIntensity or cloudCover)
const DATA_FIELD = ‘precipitationIntensity’;

// set the ISO timestamp (now for all fields, up to 6 hour out for precipitationIntensity)
const TIMESTAMP = (now);

// initialize the map
function initMap() {
var map = new google.maps.Map(document.getElementById(‘map’), {
zoom: 7,
center: {
lat: 30.318050,
lng: -87.704060
}
});

// inject the tile layer
var imageMapType = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
if (zoom > 12) {
return null;
}

  return `https://api.tomorrow.io/v4/map/tile/${zoom}/${coord.x}/${coord.y}/${DATA_FIELD}/${TIMESTAMP}.png?apikey=${API_KEY}`;
},
tileSize: new google.maps.Size(256, 256)

});

map.overlayMapTypes.push(imageMapType);
}


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *