api标题仅出现在第一个标记上

api标题仅出现在第一个标记上

本文介绍了Gmap V3 api标题仅出现在第一个标记上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Firefox,标记标题仅出现在第一个被遮蔽的标记上。任何后续鼠标悬停都不会产生标题。标题与Chrome,IE等工作正常。



以前有几个关于这方面的问题。 (请参阅



答案表明这是api实验版的问题。



gmaps api问题是相关的。

正如附件显示,问题不一定通过使用& v = 3 来解决。



我错过了什么?

 <!DOCTYPE html> 
< html>
< head lang =en>
< meta charset =UTF-8>
< title> title>

< script src =// ajax.googleapis.com/ajax/libs/jquery /1.8.3/jquery.min.js\"></script>
< script src ='https://maps.googleapis.com/maps/api/js?v = 3& sensor = false'>< / script>
< script type =text / javascript>
函数mapDisplay(){
var locations = [
[-42.0,147.0,marker 1],
[-42.3,147.9,marker 2],
[-42.2,147.45,marker 3],
[-42.8,147.9,marker 4]
];
$(#map)。css({'height':'600px'});

var map = new google.maps.Map(document.getElementById('map'),{
mapTypeId:google.maps.MapTypeId.ROADMAP
});

var marker,point;
var bounds = new google.maps.LatLngBounds();

for(var i = 0; i< locations.length; i ++){
point = new google.maps.LatLng(locations [i] [0],locations [i] [4]);
marker = new google.maps.Marker({
position:point,
map:map,$ b $ title:locations [i] [5]
});

bounds.extend(marker.position);
}
map.fitBounds(bounds);
if(map.getZoom()> 10){
map.setZoom(10);
}
}
< / script>
< / head>
< body onload =mapDisplay()>
< div id =mapstyle =height:90%; width:90%;>< / div>
< / body>
< / html>


解决方案

这是一个API版本问题。 :

 < script src ='https://maps.googleapis.com/maps/api/js?v = 3.0& sensor =假'>< /脚本> 

修复了它(至少对我而言)



(投票表示兴趣/关注状态)


Using Firefox, marker titles appear only for the first marker that is moused over. Any subsequent mouseovers yield no title. Titles work fine with Chrome, IE etc.

There have been several previous questions about this. (see Google Maps Marker title no longer appears as tooltip on hover

The answers have indicated that this was a problem in the experimental version of the api.

gmaps api issues https://code.google.com/p/gmaps-api-issues/issues/detail?id=6931 is related.

As the attached jFiddle shows, the problem is not necessarily fixed by using &v=3.

Have I missed something?

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Titles Fail</title>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src='https://maps.googleapis.com/maps/api/js?v=3&sensor=false'></script>
<script type="text/javascript">
    function mapDisplay(){
        var locations =  [
            [-42.0, 147.0, "marker 1"],
            [-42.3, 147.9, "marker 2"],
            [-42.2, 147.45, "marker 3"],
            [-42.8, 147.9, "marker 4"]
        ];
            $("#map").css({'height': '600px'});

            var map = new google.maps.Map(document.getElementById('map'), {
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });

            var marker, point;
            var bounds = new google.maps.LatLngBounds();

            for (var i = 0; i < locations.length; i++) {
                point = new google.maps.LatLng(locations[i][0], locations[i][4]);
                marker = new google.maps.Marker({
                    position: point,
                    map: map,
                    title: locations[i][5]
                });

                bounds.extend(marker.position);
            }
            map.fitBounds(bounds);
            if(map.getZoom()> 10){
                map.setZoom(10);
            }
    }
</script>
</head>
<body onload="mapDisplay()">
<div id="map" style="height: 90%; width: 90%;"></div>
</body>
</html>
解决方案

It is an API version issue. The "frozen version" (currently v3.16):

<script src='https://maps.googleapis.com/maps/api/js?v=3.0&sensor=false'></script>

fixes it (at least for me)

fiddle

current issue in the issue tracker (vote to indicate interest/follow status)

这篇关于Gmap V3 api标题仅出现在第一个标记上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:50