谷歌地图API V3 - 自定义.GIF标记在IE中不显示时调整大小
问题描述:
我一直在试图弄清楚这一点了一段时间,似乎无法得到它的工作或在留言板上找到解决方案。谷歌地图API V3 - 自定义.GIF标记在IE中不显示时调整大小
我想在使用API V3的谷歌地图中使用自定义标记。它需要是.gif文件而不是.png,因为IE似乎不支持.png中的alpha通道。 它还需要缩小规模,因为它是一个相当复杂的图像,我正在使用文本,并且当您在photoshop/paint中调整图像大小时,所有细节都会丢失并且变得非常像素化。我发现唯一的解决方法似乎是通过在.html文件中对其进行缩放。
我目前的HTML解决方案可以在FF,Chrome,Safari & Opera中使用,但不能在IE浏览器中使用(我甚至没有地图只是一个空白的白屏)。
任何帮助将不胜感激,因为我在网上搜索似乎没有得到任何地方。我的HTML文件如下打印....
感谢
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Map</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var latLng = new google.maps.LatLng(51.500656, -0.124594);
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 14,
center: latLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: latLng,
draggable: true,
map: map,
icon: new google.maps.MarkerImage("http://www.activityvillage.co.uk/images/Big_Ben.gif", null, null, new google.maps.Point(66, 200), new google.maps.Size(136, 200)),
});
var label = new Label({
map: map
});
label.bindTo('position', marker, 'position');
label.bindTo('text', marker, 'position');
};
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="height: 100%; width: 100%"></div>
</body>
</html>
答
尝试在标记结构中去掉最后一个逗号:
var marker = new google.maps.Marker({
position: latLng,
draggable: true,
map: map,
icon: new google.maps.MarkerImage(
"http://www.activityvillage.co.uk/images/Big_Ben.gif",
null,
null,
new google.maps.Point(66, 200),
new google.maps.Size(136, 200)
)
});
我的地图没有显示在所有因为类似的错误。引用Zepher Dev:
“Javascript中有很多可能的错误可以解释失踪的谷歌地图。但是,我的问题是尾随逗号.IE7(有时IE8)不喜欢尾随逗号,因为它期望标识符 - 因此警告:“预期标识符”。
希望这适用于亚!