【问题标题】:Google Maps API V3 - Custom .GIF Markers not showing in IE when resizedGoogle Maps API V3 - 调整大小时不显示在 IE 中的自定义 .GIF 标记
【发布时间】:2012-01-07 18:54:52
【问题描述】:

我一直在尝试解决这个问题,但似乎无法让它工作或在留言板上找到解决方案。

我正在尝试使用 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>​

【问题讨论】:

    标签: internet-explorer api resize maps


    【解决方案1】:

    尝试删除标记结构中的最后一个逗号:

    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 中有许多可能的错误可能导致缺少 Google 地图。但是,我的问题是尾随逗号。IE7(有时是 IE8)不喜欢尾随逗号,因为它需要一个标识符 - 因此警告: “预期的标识符。”

    希望这对你有用!

    【讨论】:

      猜你喜欢
      • 2011-12-27
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 2012-08-15
      • 2012-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多