JSFiddle - React, Tailwind, and code Playground
by itsazzad
JavaScript
"use strict";
const citymap = {
home: {
center: {
lat: 23.743693,
lng: 89.646694
},
population: 1
},
antipod: {
center: {
lat: -23.743693,
lng: -90.353306
},
//population: 1.82*1000*1000//Peru
population: 2*1000*1000//Chile
},
};
function initMap() {
// Create the map.
const map = new google.maps.Map(document.getElementById("map"), {
zoom: 4,
center: citymap.antipod.center,
mapTypeId: "terrain"
}); // Construct the circle for each value in citymap.
// Note: We scale the area of the circle based on the population.
for (const city in citymap) {
// Add the circle for this city to the map.
const cityCircle = new google.maps.Circle({
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35,
map,
center: citymap[city].center,
radius: citymap[city].population
});
}
}