【发布时间】:2014-06-08 04:19:45
【问题描述】:
我有以下代码:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div class="row">
<div class="col-md-6" id="googleMap" style="height:500px;"></div>
</div>
<script>
function initialize() {
var mapProp = {
center: new google.maps.LatLng(44.6656, -83.5753),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap")
,mapProp);
var marker = new google.maps.Marker({
position: mapProp,
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
地图显示正常,但我无法添加标记。我收到以下错误:
setPosition: not a LatLng or LatLngLiteral: in property lat: not a number
我看不出纬度和经度是如何无效的,因为生成的地图显示了正确的位置。但没有标记。
【问题讨论】:
-
mapProp 不是 google.maps.LatLng 对象。