JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyATvgBcRYVmkSFoTKVDSQPefSu7-LgXYSA&sensor=false"type="text/javascript"></script>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 50% }
</style>
<script>
var poly;
var geodesicPoly;
function initialize() {
var mapOptions = {
zoom: 3,
center: new google.maps.LatLng(34, -40.605),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
map.setOptions({ draggableCursor: 'crosshair' , draggingCursor: 'pointer' });
var polyOptions = {};
poly = new google.maps.Polyline(polyOptions);
poly.setMap(map);
var geodesicOptions = {
strokeColor: '#CC0099',
strokeOpacity: 1.0,
strokeWeight: 3,
geodesic: true
}
geodesic = new google.maps.Polyline(geodesicOptions);
geodesic.setMap(map);
// Add a listener for the click event
google.maps.event.addListener(map, 'click', function(event) {
var marker = new google.maps.Marker({
position: event.latLng,
map: map,
draggable:true
});
var path = geodesic.getPath();
path.push(event.latLng);
});
}
function update() {
var path = [marker.getPosition()];
poly.setPath(path);
...