Javascript和谷歌地图API
问题描述:
我很烦人,我的发际线在砧板上。当我在这个网站上整合了地图API时,ritaknoetze.com,一切都很完美。Javascript和谷歌地图API
但是,复制一个不同的演示网站的确切代码,scarabpaper,地图根本不显示?有人能告诉我我做错了什么吗?
这是我从谷歌本身,我修改了我的WordPress主题/安装了代码:
的JavaScript:
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(-34.009839, 22.78101);
var myOptions = {
zoom: 9,
center: myLatlng,
navigationControl: true,
mapTypeControl: false,
scaleControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var image = '<?php bloginfo('template_url')?>/assets/googlemaps_marker.png';
var myLatLng = new google.maps.LatLng(-34.009839, 22.78101);
var beachMarker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image
});
}
</script>
我的HTML,其中Java云:
<div class="contact_container">
<div id="map_canvas"></div>
<div class="clearfloat"></div>
</div>
我的受影响div的CSS
#map_canvas {
width: 880px;
height: 300px;
margin-left: 10px;
margin-bottom: 30px;
margin-top: 10px;
float: left;
border: 1px solid #dedcdc;}
.contact_container { /*container for ALL the contact info*/
background-color: #fff;
border: 1px solid #dedcdc;
width: 900px;
margin-top: 30px;
padding: 20px;
padding-bottom: 0;}
任何帮助将大大赞赏 ...
答
你永远调用initialize()
方法。如果您调用该方法,即使使用控制台,它也能正常工作。
你可以附加onload ='javascript:initialize();'在身体 – kjy112 2011-02-09 23:27:24