Google Maps API标记图像在Internet Explorer中不显示 [英] Google Maps API Marker Images not showing in Internet Explorer

查看:90
本文介绍了Google Maps API标记图像在Internet Explorer中不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Maps API Javascript V3,并且在Internet Explorer中存在一个问题,我的标记图像未显示,但根据Adobe Browserlab,其他浏览器没有问题。正在从称为隐藏的div读取坐标。以下是我的代码:

 < script type =text / javascript> 
函数initialize(){
var cent = new google.maps.LatLng([security block]);
var myOptions = {
zoom:11,
center:cent,
mapTypeId:google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById(map_canvas),myOptions);
var locations = document.getElementById(hidden)。innerHTML;
var spLocations = locations.split(< br>);
var spLength =(spLocations.length)-1;
var letter =A;
for(var i = 0; i< spLength; i ++){
var formLocations = spLocations [i] .split(,);
var image =http://www.google.com/intl/zh-CN/ALL/mapfiles/marker_black\"+letter+\".p​​ng;
var myLatLng = new google.maps.LatLng(formLocations [0],formLocations [1]);
var marker = new google.maps.Marker({
position:myLatLng,
icon:image,
map:map
});
letter = String.fromCharCode(letter.charCodeAt()+ 1);
}
}
< / script>


解决方案

我借助Google的地图API论坛。



由于我是通过换行分割单个坐标< br> Internet Explorer大写标签,所以我需要迎合大写字母,否则坐标不会分开。



解决方法是更改​​此行:

  var locations = document.getElementById(hidden)。innerHTML; 

至此:

 ($隐藏)。 

请注意,未来这些人中有

I'm using Google Maps API Javascript V3 and I have a problem where in Internet explorer, my marker images aren't appearing but according to Adobe Browserlab, other browsers have no problem. The coordinates are being read from a div called "hidden". Here is my code:

<script type="text/javascript"> 
function initialize() {
 var cent = new google.maps.LatLng([security block]);
 var myOptions = {
   zoom: 11,
   center: cent,
   mapTypeId: google.maps.MapTypeId.ROADMAP
 }
 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 var locations = document.getElementById("hidden").innerHTML;
 var spLocations = locations.split("<br>");
 var spLength = (spLocations.length)-1;
 var letter = "A";
 for(var i=0; i<spLength; i++){
 var formLocations = spLocations[i].split(",");
 var image = "http://www.google.com/intl/en_ALL/mapfiles/marker_black"+letter+".png";
 var myLatLng = new google.maps.LatLng(formLocations[0], formLocations[1]);
 var marker = new google.maps.Marker({
      position: myLatLng,
      icon: image,
      map: map
  });
 letter = String.fromCharCode(letter.charCodeAt() + 1);
 }
}
</script>    

解决方案

I have sussed it out with the help of Google's Map API Forum.

As I was splitting the individual co-ordinates by Line Break <br> Internet Explorer capitalises the tag so I'd need to cater for upper case characters also, or the co-ordinates would not be separated.

A solution would be to change this line:

var locations = document.getElementById("hidden").innerHTML;

To this:

var locations = document.getElementById("hidden").innerHTML.toLowerCase();

Watch out for this in future guys

这篇关于Google Maps API标记图像在Internet Explorer中不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆