Google地图StreetView InfowIndows在地图上打开 [英] Google Maps StreetView InfowIndows opening on map

查看:242
本文介绍了Google地图StreetView InfowIndows在地图上打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Google Maps应用程序中添加标记和InfoWindow时,标记会正确添加到地图和默认的StreetView全景图中。

我还将InfoWindows添加到这两个标记的副本通过调用我的 bindInfoWindow 函数一次使​​用地图作为参数,一次使用StreetView全景作为参数。



直到几个星期前,这个工作才完成。

现在,由于某些原因,InfoWindows都显示在地图上,附加到地图标记。



我创建了一个简单的小提琴

a>(基于这个公共小提琴),它显示了 here。



基本上我以正常的方式创建标记和InfoWindows: p>

  var myMarker = new google.maps.Marker({
map:map,
position:new google.maps.LatLng(-34.397,150.644),
title:我的标记,
draggable:true,
} );

然后我使用我的bindInfoWindow函数

 函数bindInfoWindow(marker,mapOrStreetView,whichInWindow,html,openWindow,markerId){
openWindow =((typeof openWindow ==='undefined')?false:openWindow);
markerId =((typeof markerId ==='undefined')?'':markerId);
google.maps.event.addListener(marker,'click',function(){
whichInfoWindow.setContent(html);
whichInfoWindow.open(mapOrStreetView,marker);
});
if(openWindow === true){
whichInfoWindow.setContent(html);
whichInfoWindow.open(mapOrStreetView,marker);
}
}

为标记创建onClick动作并打开如果需要,InfoWindows会自动运行。

  var myMarkerInfoWindow = new google.maps.InfoWindow; 
bindInfoWindow(myMarker,map,myMarkerInfoWindow,< h1>我的地图信息窗口文本< br />< br />< / h1>,true);
var myMarkerStreetViewInfoWindow = new google.maps.InfoWindow;
bindInfoWindow(myMarker,defaultStreetViewPanorama,myMarkerStreetViewInfoWindow,< h1> My StreetView Info Window< / h1>,true);

直到大约一两个星期前,这个工作完美无缺,但InfoWindows突然间都出现在地图上,而不是一个出现在地图上,一个出现在默认的StreetView上。



小提琴,您可以清楚地看到StreetView InfoWindow在主地图InfoWindow的顶部打开,尽管已指定在StreetView上打开。 p>

请注意, map 是我的地图对象, defaultStreetViewPanorama 是通过

  var defaultStreetViewPanorama = map.getStreetView();检索StreetView Panormama对象。 

紧接在创建地图对象之后,并在设置StreetView选项之前。请注意,正确设置了StreetView选项 ,所以看起来 map.getStreetView()正在返回正确的对象。

解决方案

Google在v3.25中破解了这个功能。

v3.24是最后一个版本工作正常。



v3.24已经停用并且不再可用 - 在此期间似乎没有任何简单的解决方法。



此问题已记录在Google的错误跟踪器中,位于 https://code.google.com/p/gmaps-api-issues/issues/detail?id=9925 已被接受,但在撰写本文时还没有被修复。



如果/有任何进展,我会更新这个答案。


When I add a marker and InfoWindow to my Google Maps application the marker is correctly added to both the map and the default StreetView panorama.

I also add InfoWindows to both copies of the marker by calling my bindInfoWindow function once with the map as an argument and once with the StreetView panorama as an argument.

This was working perfectly until a few weeks ago.

Now, for some reason, both InfoWindows are being displayed on the map, attached to the map marker.

I have created a simple fiddle (based on this public fiddle) which shows the problem here.

Basically I create the marker and InfoWindows in the normal way:

    var myMarker = new google.maps.Marker({
            map: map,
                position: new google.maps.LatLng(-34.397, 150.644),
                title: "My Marker",
                draggable:true,
            });

Then I use my bindInfoWindow function

function bindInfoWindow(marker, mapOrStreetView, whichInfoWindow, html, openWindow,markerId) {
    openWindow = ((typeof openWindow === 'undefined')?false:openWindow);
    markerId = ((typeof markerId === 'undefined')?'':markerId);
    google.maps.event.addListener(marker, 'click', function() {
        whichInfoWindow.setContent(html);
        whichInfoWindow.open(mapOrStreetView, marker);
    });
    if ( openWindow === true ) {
        whichInfoWindow.setContent(html);
        whichInfoWindow.open(mapOrStreetView, marker);
    }
}

to create the onClick actions for the markers and also open the InfoWindows automatically if required.

            var myMarkerInfoWindow = new google.maps.InfoWindow;
            bindInfoWindow(myMarker, map, myMarkerInfoWindow, "<h1>My Map Info Window Text<br /> <br /></h1>", true);
            var myMarkerStreetViewInfoWindow = new google.maps.InfoWindow;
            bindInfoWindow(myMarker, defaultStreetViewPanorama, myMarkerStreetViewInfoWindow, "<h1>My StreetView Info Window Text</h1>", true);

Up until about a week or two ago this was working perfectly, but all of a sudden the InfoWindows are both appearing on the map, rather than one appearing on the map and one appearing on the default StreetView.

In the fiddle, you can clearly see that the StreetView InfoWindow has opened over the top of the main map InfoWindow despite having been specified to open on the StreetView.

Note that map is my map object and defaultStreetViewPanorama is the StreetView Panormama object retrieved with

var defaultStreetViewPanorama = map.getStreetView();

just after the map object is created and just before the StreetView options are set. Note that the StreetView options are being correctly set, so it seems that map.getStreetView() is returning the correct object.

解决方案

Google broke this functionality in v3.25.

v3.24 was the last version which worked correctly.

v3.24 has been retired and is no longer available - there does not seem to be any simple workaround in the meantime.

The issue has been logged with Google on their bug-tracker at https://code.google.com/p/gmaps-api-issues/issues/detail?id=9925 and has been accepted but at the time of writing has not been fixed.

I will update this answer if/when there is any progress.

这篇关于Google地图StreetView InfowIndows在地图上打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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