2
此代碼一直工作,直到我昨晚更新。
該代碼在我的本地主機上完美工作,但在測試服務器上出現錯誤。錯誤消息(來自Firebug)是"map.set_center is not a function"
。爲什麼我會得到「map.set_center不是函數」?
那麼爲什麼這不再在我的服務器上工作?
function googleMapInit()
{
if (jQuery('#map_canvas').length > 0) {
var currentLocation = jQuery('#geomap_ddlCity :selected').text() + ', ' + jQuery('#geomap_ddlCountry :selected').text();
var options = {zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }
var map = new google.maps.Map(document.getElementById("map_canvas"), options);
var geocoder = new google.maps.Geocoder();
//Center map for current selected city
geocoder.geocode(
{
address: currentLocation}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK && results.length) {
alert(results[0].geometry.location);
map.set_center(results[0].geometry.location);
} else
{
var oslo = new google.maps.LatLng(59.9167, 10.75);
map.set_center(oslo);
}
}
);
}
}
就是這樣。謝謝! – Steven
不客氣:-)玩得開心! –