JSFiddle - React, Tailwind, and code Playground
HTML
<div id="map_canvas" style="width:100%;height:100%;"></div>
<script>
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(-6.175110, 106.865036);
var myOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
streetViewControl: false,
fullscreenControl: true,
center: chicago,
scrollwheel: false
}
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
directionsDisplay.setMap(map);
calcRoute();
}
function calcRoute() {
var request = {
origin: '1.100259,104.0369356',
destination: '1.0972226,104.0362701',
optimizeWaypoints: true,
travelMode: google.maps.DirectionsTravelMode.WALKING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
var route = response.routes[0];
var summaryPanel = document.getElementById('directions_panel');
} else {
alert('directions response '+status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>