在firefox中的相对位置导致google-map-markers可点击区域的问题 [英] Position relative in firefox causing problems with google-map-markers clickable area

查看:190
本文介绍了在firefox中的相对位置导致google-map-markers可点击区域的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在地图div之前添加文字(或其他内容)时,google-map-marker周围的可点击区域会移动/放错位置。
它在chrome,即等工作正常 - 只有firefox似乎引起这个问题(就我所见)。
当在web控制台中将map-div的elementstyle从'relative'改成'static'时,问题就消失了。

The clickable area around a google-map-marker is shifting/misplaced when text (or other content) is added before the map-div. It is working fine in chrome, ie etc. - only firefox seems to cause this problem (as far as I can see). When - in web-console - changing map-div's elementstyle from 'relative' to 'static' the problem is gone.

googles地图示例 - 如果我取消注释lorem文本地图标记可点击区域是移动/错位。任何关于如何解决问题的建议(如果有问题 - 我可能错过了一些明显的东西):

The code below is borrowed from googles map-examples - if I uncomment the lorem-text the map-markers clickable area is moving/misplaced. Any suggestions on how to solve the problem (if there is a problem - I might have missed something obvious):

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Complex icons</title>
    <style>
        html, body, #map-canvas
        {
            height: 800px;
            width: 800px;
            margin: 0px;
            padding: 0px;
        }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
    <script>
        function initialize() {
            var mapOptions = {
                zoom: 10,
                center: new google.maps.LatLng(-33.9, 151.2)
            }
            var map = new google.maps.Map(document.getElementById('map-canvas'),
                                          mapOptions);

            setMarkers(map, beaches);
        }

        var beaches = [
          ['Bondi Beach', -33.890542, 151.274856, 4],
          ['Coogee Beach', -33.923036, 151.259052, 5],
          ['Cronulla Beach', -34.028249, 151.157507, 3],
          ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
          ['Maroubra Beach', -33.950198, 151.259302, 1]
        ];

        function setMarkers(map, locations) {
            var image = {
                url: 'https://www.google.com/support/enterprise/static/geo/cdate/art/dots/blue_dot.png',
                size: new google.maps.Size(21, 21),
                origin: new google.maps.Point(0, 0),
                anchor: new google.maps.Point(10, 10)  
            };

            var shape = {
                coords: [0,0, 0,21, 21,21, 21,0],
                type: 'poly'
            };
            for (var i = 0; i < locations.length; i++) {
                var beach = locations[i];
                var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
                var marker = new google.maps.Marker({
                    position: myLatLng,
                    map: map,
                    icon: image,
                    shape: shape,
                    title: beach[0]
                });
            }
        }

        google.maps.event.addDomListener(window, 'load', initialize);

    </script>
</head>
<body>

    <!--<p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit fusce vel sapien elit in malesuada semper mi, id sollicitudin urna fermentum ut fusce varius nisl ac ipsum gravida vel pretium tellus.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit fusce vel sapien elit in malesuada semper mi, id sollicitudin urna fermentum ut fusce varius nisl ac ipsum gravida vel pretium tellus.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit fusce vel sapien elit in malesuada semper mi, id sollicitudin urna fermentum ut fusce varius nisl ac ipsum gravida vel pretium tellus.
    </p>-->

    <div id="map-canvas"></div>

</body>
</html>


推荐答案

尝试更改js src从v = 3.exp到v = 3

Try changing the js src from v=3.exp to v=3

这篇关于在firefox中的相对位置导致google-map-markers可点击区域的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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