I'm having an issue with the code below. It should display a map and a div section, but for some reason, it's not showing the marker point on the map. Can anyone provide assistance? Thank you in advance!
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> </script>
<script>
var myCenter = new google.maps.LatLng(17.382094947877505,78.431396484375);
var geocoder, map;
function initialize() {
geocoder = new google.maps.Geocoder();
var mapProp = {
center: myCenter,
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
}
function codeAddress() {
var address = document.getElementById('address').value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="panel">
<input type="address" type="textbox" value="Hyderabad, Telangana">
<input type="button" value="Geocode" onclick="codeAddress();">
</div>
<div id="googleMap" style="width:1200px;height:800px;"></div>
</body>
</html>