JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://maps.googleapis.com/maps/api/js?libraries=geometry,places&ext=.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
<div id="map_canvas"></div>
<input type="text" id="input" value="fghfghfghgf" >
CSS
html,
body,
#map_canvas {
height: 350px;
width: 550px;
margin: 0px;
padding: 0px
}
JavaScript
$(document).ready(function () {
var input = $('#input').val();
var map;
function initialize()
{
var latlng = new google.maps.LatLng(21.16536,72.79387);
var NewLatLng = new google.maps.LatLng(input);
var myOptions = {
zoom: 5,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker
(
{
position: new google.maps.LatLng(21.1673643, 72.7851802),
map: map,
title: 'Click me'
}
);
setInterval(function() { marker.setPosition(NewLatLng);}, 2000);
var infowindow = new google.maps.InfoWindow({
content: 'Location info:<br/>SVNIT Post Office, Dumas Rd, Surat<br/>LatLng:<br/>21.1673643, 72.7851802'
});
google.maps.event.addListener(marker, 'click', function ()
{
infowindow.open(map, marker);
setTimeout(function(){infowindow.close();}, '5000');
});
}
window.onload = initialize;
});