GooglemapAPI调用时一个诡异的有关问题,IE下正常,其他浏览器在asp页面正常,生成静态后不显示map了
Google地图API调用时一个诡异的问题,IE下正常,其他浏览器在asp页面正常,生成静态后不显示地图了。
调用的Google Map API,生成静态页面之后,在IE下是正常的,但是放在Chrome,FF浏览器里面就一片空白了。
但是如果没生成静态,就是使用xxxx.asp?id=1这样的url访问时,这个地图又正常了!
地图调用的源码是:
在chrome下的错误信息是:
在FF下除了
完全不知道怎么回事了……
------解决方案--------------------
基本是编码错误
调用的Google Map API,生成静态页面之后,在IE下是正常的,但是放在Chrome,FF浏览器里面就一片空白了。
但是如果没生成静态,就是使用xxxx.asp?id=1这样的url访问时,这个地图又正常了!
地图调用的源码是:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=MyGoogleAPIkey&sensor=false&language=en"></script>
<script type="text/javascript">
$(window).load(function(){
var geocoder;
var map;
geocoder = new google.maps.Geocoder();
var mapOptions = {
center: new google.maps.LatLng(39.90403, 116.40752599999996),
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
//map_canvas是显示地图的一个DIV
map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
//hotelLocal是一个放地址的hidden元素,用来提交到google取得地理编码,也就是坐标。
var address = document.getElementById('hotelLocal').value;
geocoder.geocode({'address': address},function(results, status){
if (status == google.maps.GeocoderStatus.OK){
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position:results[0].geometry.location
});
}else {
alert("Geocode was not successful for the following reason: " + status);
}
});
});
</script>
在chrome下的错误信息是:
Uncaught SyntaxError: Unexpected token ILLEGAL maps.gstatic.com/intl/en_ALL/mapfiles/api-3/14/14/main.js:1
在FF下除了
[17:47:02.730] SyntaxError: illegal character @ http://maps.gstatic.com/intl/en_ALL/mapfiles/api-3/14/14/main.js:1以外,还有个
[17:47:04.184] TypeError: google.maps.Geocoder is not a constructor @ xxxxxxx.html:237
完全不知道怎么回事了……
------解决方案--------------------
基本是编码错误