I can update the google map marker position but I cannot update the google map position. It does not centres the map to the latitude and longitude position given
var myLatlng;
var map;
var infowindow;
var latitude;
var longtitude;
var marker;
loadMap();
function loadMap()
{
myLatlng = new google.maps.LatLng(54.91252, -1.37664);
var mapOptions = {
zoom: 17,
center: myLatlng
};
map = new google.maps.Map(document.getElementById("googlemaps"), mapOptions);
var contentString = '<h5>The Mew </h5>';
infowindow = new google.maps.InfoWindow({
content: contentString
});
marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "The Mew",
animation: google.maps.Animation.DROP
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
infowindow.open(map, marker);
}
function updatePosition()
{
latitude = document.getElementById('latitude');
longtitude = document.getElementById('longtitude');
myLatlng = new google.maps.LatLng(latitude, longtitude);
marker.setPosition(myLatlng);
map.setCenter(myLatlng);
}
<input type="text" id="latitude" />
<input type="text" id="longtitude" />
<a onclick="updatePosition()" >update </a>