简体   繁体   English

Google Maps InfoBox缩放时正在改变位置

[英]Google maps InfoBox is changing position while zooming

Is this a common problem by people? 这是人们的普遍问题吗? here screenshots of the issue in this one it is positioned right: http://s23.postimg.org/qqglxorkr/Screen_Shot_2016_04_06_at_16_11_31.png 这里是此问题的屏幕截图,它的位置正确: http : //s23.postimg.org/qqglxorkr/Screen_Shot_2016_04_06_at_16_11_31.png

Here it is zoomed in but the infoBox is not positioned right. 在这里它被放大了,但是infoBox的位置不正确。 http://s27.postimg.org/f1i9ouryr/Screen_Shot_2016_04_06_at_16_11_08.png http://s27.postimg.org/f1i9ouryr/Screen_Shot_2016_04_06_at_16_11_08.png

Does someone knows how to line out this infobox no matter what above the house? 不管房子上方是什么,有人知道如何对这个信息框进行排队吗?

I had something in common here you can see the issue: How do i access all my google maps markers 我在这里有一个共同点,您可以看到这个问题: 如何访问我的所有Google Maps标记

Code below shows how it is setup: 下面的代码显示了如何设置:

for (i = 0; i < locations.length; i++) {
        var myLatLng = {lat: locations[i][0].lat, lng: locations[i][0].lng};

    marker = new google.maps.Marker({
        position: myLatLng,
        icon: icon1,
        map: map
    });

    setInfoWindow(marker);
    setMarker(marker);
    setMarkerSize(marker);
}

function setInfoWindow(marker) {
    var infobox = new InfoBox({
        content: contentString,
        disableAutoPan: false,
        maxWidth: 170,
        pixelOffset: new google.maps.Size(-110, -50),
        zIndex: null,
        alignBottom: true,
        boxStyle: {
            background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') no-repeat",
            opacity: 1,
            width: "200px"
        },
        closeBoxMargin: "12px 4px 2px 2px",
        closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
        infoBoxClearance: new google.maps.Size(1, 1)
    });

   map.addListener('zoom_changed', function() {
        if (map.getZoom() === 18) {
            infobox.pixelOffset = new google.maps.Size(-110, -190);
            console.log(infobox.pixelOffset)
        }
    });
}

It is logging the new values but it is not changing its position. 它正在记录新值,但未更改其位置。

About the hours of frustration, we understand. 关于无奈的时间,我们了解。 We've all been there, it goes with the turf. 我们都去过那里,它伴随着草皮。

Try this instead: 尝试以下方法:

infobox.setOptions({pixelOffset: new google.maps.Size(-110, -190)});

Google maps objects typically do not update their appearance when you set properties directly. 直接设置属性时,Google地图对象通常不会更新其外观。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM