JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<button type="button" id="btnAreaCamp" class="btn btn-default">Course area</button>
<button type="button" id="btnCasaClub" class="btn btn-default" disabled="disabled">Club house</button>
</div>
<div id="googleMap" style="width:600px;height:300px"></div>
<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing,geometry"></script>
<script src="https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerwithlabel/src/markerwithlabel.js"></script>
<script>
var CREAR_CAMP = {
map: null,
polygonArea: null,
markerWithLabelCasaClub: null
};
google.maps.event.addDomListener(window, "load", initMap);
function initMap() {
var mapOptions = {
center: {
lat: 41.462853,
lng: 2.076703
},
zoom: 15,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
CREAR_CAMP.map = new google.maps.Map(document.getElementById('googleMap'), mapOptions);
document.getElementById("btnAreaCamp").addEventListener("click", function() {
this.disabled = true;
var icon = document.createElement("i");
icon.className = "fa fa-cog fa-spin";
icon.style.marginRight = "5px";
this.insertBefore(icon, this.childNodes[0]);
var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.NONE,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [
google.maps.drawing.OverlayType.POLYGON
]
},
polygonOptions: {
clickable: true,
draggable: true,
editable: true,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35,
zIndex: 1
}
});
drawingManager.setMap(CREAR_CAMP.map);
var that = this;
google.maps.event.addListener(drawingManager, 'polygoncomplete',...
CSS
html,
body {
margin: 0;
padding: 0;
}
.markerLabel {
color: red;
background-color: white;
font-family: "Lucida Grande", "Arial", sans-serif;
font-size: 10px;
font-weight: bold;
text-align: center;
width: 60px;
border: 2px solid black;
white-space: nowrap;
}