-1
嗨,我使用谷歌API來顯示在地圖上的多個點多點,但它顯示InvalidValueError: setCenter: not a LatLng or LatLngLiteral: not an Object
顯示在谷歌地圖
<script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
var map;
var geocoder;
var centerChangedLast;
var reverseGeocodedLast;
var currentReverseGeocodeResponse;
function initialize() {
var myOptions = {
zoom: 40,
center: (10.566057,76.235787), // set some default latlng here, e.g $data[0]['lat'], $data[0]['lng']
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
geocoder = new google.maps.Geocoder();
$.ajax({
url : 'getDataForMap',
type : 'POST',
dataType : 'json',
beforeSend : function() {
},
complete : function() {
},
success : function(responseData) {
for (var i = 0; i < responseData.legth; i++) {
var latlng = new google.maps.LatLng(responseData[i].latitude+','+responseData[i].longitude);
var marker = new google.maps.Marker({
position: (10.566057,76.235787),
map: map,
title: responseData[i].name
});
}
}
});
}
<div id="map" style="width:200px; height:200px">
<div id="map_canvas" style="width:100%; height:200px"></div>
<div id="crosshair"></div>
</div>
<button onclick="initialize();">Refresh</button>
做新的動態lat和從服務器端WIL登錄l點擊按鈕顯示。 – boycod3