In updatePosition
the information you're assigning to latitude and longitude are the DOM nodes of those input fields but you want to assign the value of those inputs instead. Also, you need to ensure that the text you're grabbing from those values is converted to a number for LatLng
to accept them properly. You can use parseInt
for that. Don't forget the radix.
function updatePosition() {
latitude = parseInt(document.getElementById('latitude').value, 10);
longtitude = parseInt(document.getElementById('longtitude').value, 10);
myLatlng = new google.maps.LatLng(latitude, longtitude);
marker.setPosition(myLatlng);
map.setCenter(myLatlng);
}