亲爱的程序员们:
有没有人可以帮我解决我在想要强制googlemap在卫星视图中显示时遇到的真正头痛的问题?由于API文档的原因,下面的代码确实是必须要做的。尽管如此,它仍然以正常贴图模式显示。
有没有人遇到过类似的问题,或者看到过我无法识别的bug?
感谢您的阅读和您的努力。
PHP:
<?php if($gmapaddress!=""){ ?>
<div class="gmap"><div id="gmap_inner"></div></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=es"></script>
<script type="text/javascript" src="<?php echo $template_uri;?>/js/jquery.gmap.js"></script>
<script>
jQuery(window).load(function(){
//set google map with marker
jQuery("#gmap_inner").gMap({
markers: [{
address: '<?php echo $gmapaddress; ?>'<?php if($gmapinfo!="") {?>,
html: '<?php echo $gmapinfo; ?>' <?php } ?>
}],
zoom: <?php echo $gmapzoom;?>,
mapOptions: [{mapTypeID: "satellite"}]
});
});
</script>
<?php } ?>生成的HTML/javascript:
<div class="gmap"><div id="gmap_inner"></div></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=es"></script>
<script type="text/javascript" src="http://localhost:8888/csmlu/wp-content/themes/zeitgeist/js/jquery.gmap.js"></script>
<script>
jQuery(window).load(function(){
//set google map with marker
jQuery("#gmap_inner").gMap({
markers: [{
address: '-40.297357°,-73.084091°'
}],
zoom: 18,
mapOptions: [{mapTypeId: "satellite"}]
});
});
</script>发布于 2014-03-07 06:29:11
Javascript区分大小写。MapTypeId选项有一个小写的"d":
mapOptions: [{mapTypeID: "satellite"}] 应该是:
mapOptions: [{mapTypeId: google.maps.MapTypeId.SATELLITE}] 更新:您正在使用的插件仍在使用deprecated (and turned off) Google Maps Javascript API v2,其语法和选项不同,请将maptype属性设置为G_SATELLITE_MAP没有mapOptions属性。
<script>
jQuery(window).load(function(){
//set google map with marker
jQuery("#gmap_inner").gMap({
markers: [{
address: '-40.297357,-73.084091'
}],
zoom: 18,
maptype: G_SATELLITE_MAP
});
});
</script>working example
https://stackoverflow.com/questions/22237325
复制相似问题