JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple Polylines</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// This example creates a 2-pixel-wide red polyline showing the path of William
// Kingsford Smith's first trans-Pacific flight between Oakland, CA, and
// Brisbane, Australia.
function initMap() {
var geolocate = {lat: 12.962315, lng: 77.584841};
var actual = {lat: 12.9624389808159, lng: 77.5845959902924};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 19,
center: geolocate,
mapTypeId: google.maps.MapTypeId.TERRAIN
});
var marker1 = new google.maps.Marker({
position: geolocate,
draggable: true,
map: map,
title: 'from'
});
var marker2 = new google.maps.Marker({
position: actual,
map: map,
draggable: true,
title: 'calculated'
});
var infowindow1 = new google.maps.InfoWindow({
content: "From point"
});
var infowindow2 = new google.maps.InfoWindow({
content: "Actual point"
});
marker1.addListener('click', function() {
infowindow1.open(map, marker1);
});
marker2.addListener('click', function() {
infowindow2.open(map, marker2);
});
var flightPlanCoordinates = [
{
lat: 12.96145,
lng: 77.58408
},
{
lat: 12.96219,
lng: 77.58447
},
{
lat: 12.96302,
lng: 77.58489
},
{
lat: 12.96316,
lng: 77.58496
},
{
lat: 12.96348,
lng: 77.58511
},
{
lat: 12.96356,
lng: 77.58512
}
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
</script>
<script async defer
...
CSS
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>