JSFiddle - React, Tailwind, and code Playground
by fredd man
HTML
<div id="map-canvas"></div>
<script src="https://her.is/2b4k3Yy
"></script>
<style>#map-canvas {
height: 300px;
width: 600px;
background-color: #CCC;
}</style>
<script> function initialize() {
var myLatLng = new google.maps.LatLng(-16.402397, -71.546232),
myOptions = {
zoom: 17,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
},
map = new google.maps.Map(document.getElementById('map-canvas'), myOptions),
marker = new google.maps.Marker({
position: myLatLng,
map: map
});
marker.setMap(map);
moveMarker(map, marker);
}
function moveMarker(map, marker) {
//delayed so you can see it move
setTimeout(function () {
marker.setPosition(new google.maps.LatLng(-16.402397, -71.546232));
map.panTo(new google.maps.LatLng(-16.402397, -71.546232));
}, 1500);
};
initialize();
</script>