JSFiddle - React, Tailwind, and code Playground
by sudarshanadayananda
HTML
<script src="https://maps.googleapis.com/maps/api/js?libraries=geometry,places&ext=.js"></script>
<div id="map_canvas"></div>
CSS
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
JavaScript
var geocoder;
var map;
function initialize() {
var map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(-36.8564663333, 174.7195396833),
zoom: 20,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var geoJson = {
"type": "FeatureCollection",
"count": 1,
"features": [
{
"id": 4813444,
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
174.7195396833,
-36.8564663333
],
[
174.7196494333,
-36.8563847667
],
[
174.7196634333,
-36.85637435
],
[
174.7196478167,
-36.8563614167
],
[
174.7193567667,
-36.8561201667
],
[
174.7192242167,
-36.8562234167
],
[
174.7195123,
-36.8564622333
],
[
174.7195278333,
-36.8564751167
],
[
174.7195396833,
-36.8564663333
]
]
]
]
},
"properties": {
"color": "#232121"
}
}
]
}
map.data.addGeoJson(geoJson);
map.data.setStyle(function(feature) {
var color = feature.getProperty('color');
return({
fillColor: color,
strokeWeight: 0
});
});
}
google.maps.event.addDomListener(window, "load", initialize);