我想使谷歌地圖V3與ASP MVC與數據庫中的標記一起工作。我發現這篇文章(http://mikehadlow.blogspot.com/2008/10/using-google-maps-with-mvc-framework.html?showComment=1280600518852#c4603834263614352338)的文章中描述了該API的第2版,但我無法將此v2代碼轉換爲v3。這個問題似乎在於getJSON,因爲這打破了一切。我只編輯了文章中的Google地圖代碼。我沒有得到任何與螢火蟲的錯誤。getJSON問題谷歌地圖V3
這是我的代碼使用方法:
$(function() {
$.getJSON("/Home/Map", initialise);
});
$(function initialise(mapData) {
var myLatlng = new google.maps.LatLng(-25.363882, 131.044922);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
$.each(mapData.Locations, function (i, location) {
setupLocationMarker(map, location);
});
});
$(function setupLocationMarker(map, location) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(location.LatLng.Latitude, location.LatLng.Longitude),
map: map,
title: location.Title
});
});
有人能看到什麼錯呢?
我沒有改變任何關於與舊的地圖V2代碼合作的JSON輸出。可以肯定,我只驗證了輸出的JSON和它的有效性。 – Prd 2010-09-13 14:36:58