以下代码显示地图并显示 div 部分但不显示地图上的标记点,任何人都可以帮助我提前感谢!
<!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="pannel">
<input type="address" type="textbox" value="hyderbad,Andhra Pradesh">
<input type="button" value="Geocode" onclick="codeAddress();">
</div>
<div id="googleMap" style="width:1200px;height:800px;"></div>
</body>
</html>