我不妨用小提琴来回答它。
jsFiddle -> http://jsfiddle.net/HB324/
HTML ->
<div id="hide_map">
<a href="#"> Click Me To Hide Map </a>
</div>
<div id="map_canvas"></div>
CSS ->
#map_canvas{
position:relative;
height:300px;
width:300px;
}
.overlay{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background:rgba(0,0,0,.5);
}
JavaScript ->
var geocoder;
var map;
var latlng;
jQuery(document).ready(function() {
geocoder = new google.maps.Geocoder();
var address = 'United States';
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
latlng=results[0].geometry.location;
var myOptions = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
map: map,
position: latlng,
title:address
});
}
});
});
编辑:忘记 CSS,添加 CSS