为什么会显示"map.set_center不是函数"? [英] Why do I get "map.set_center is not a function"?
本文介绍了为什么会显示"map.set_center不是函数"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码一直有效,直到我昨晚更新.
该代码可以在我的本地主机上正常运行,但是在测试服务器上却出现错误.错误消息(来自Firebug)是"map.set_center is not a function"
.
This code have been working until I updated last night.
The code works perfectly on my localhost, but I get an error on my test server. The error message (from Firebug) is "map.set_center is not a function"
.
那么为什么这在我的服务器上不再起作用?
So why is this not working on my server any more?
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);
}
}
);
}
}
推荐答案
It seems there is no set_center
method in the Map class ; you should probably use setCenter
, instead.
这篇关于为什么会显示"map.set_center不是函数"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文