JSFiddle - React, Tailwind, and code Playground
by Manuel Gertrudix
HTML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Aglomeraciones urbanas</title>
</head>
<body>
<div id="map"></div>
<a href="https://es.wikipedia.org/wiki/Anexo:Aglomeraciones_urbanas_m%C3%A1s_pobladas_del_mundo">Fuente: Wikipedia</a>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDmr2x0FWWydp93kDtbO3tgadydoc9bQVc&callback=initMap"></script>
</body>
</html>
CSS
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 95%;
}
JavaScript
var citymap = {
canton: {
center: {lat: 23.12911, lng: 113.26438499999995},
population: 48500000
},
newyork: {
center: {lat: 40.714, lng: -74.005},
population: 8405837
},
tokio: {
center: {lat: 35.6894875, lng: 139.69170},
population: 39800000
},
shanghai: {
center: {lat: 31.230416, lng: 121.473701},
population: 31100000
}
};
function initMap() {
var customMapType = new google.maps.StyledMapType([
//incluye aquĂ el array de estilos
], {
name: 'Mi estilo'
});
var customMapTypeId = 'custom_style';
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: {lat: 19.8967662, lng: -155.58278},
mapTypeControl: true,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, customMapTypeId]
}
});
map.mapTypes.set(customMapTypeId, customMapType);
map.setMapTypeId(customMapTypeId);
for (var city in citymap) {
var cityCircle = new google.maps.Circle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
center: citymap[city].center,
radius: Math.sqrt(citymap[city].population) * 100
});
}
}