-1

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

Here it is zoomed in but the infoBox is not positioned right. 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

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.

Community
  • 1
  • 1
Sireini
  • 4,142
  • 12
  • 52
  • 91
  • Please provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) that demonstrates your issue. – geocodezip Apr 06 '16 at 14:44
  • @geocodezip What is wrong with it? – Sireini Apr 06 '16 at 14:51
  • 1
    Lots of stuff: you don't make it clear what the problem is (where is the infobox supposed to be? looks pretty much same place to me in both pix), you've copy-pasted from another question without quoting the content so it looks like part of your question which is confusing, and if your problem is the same as the other question you need to make it **very** clear how its not a duplicate of the other: why doesn't the answer to that one work for you? – Jared Smith Apr 06 '16 at 15:24
  • 1
    Last but certainly not least, it appears to me that your question doesn't actually relate to the other one: in the other the problem is that the info box only works for one marker instead of many because of a classic closure-loop problem, your question AFAIK is about micro-adjusting the position of the infobox (I can't really tell) – Jared Smith Apr 06 '16 at 15:27
  • Yes I know but it is logging the changes of the pixelOffset, but it is not changing its position. Like Duncan explained which was not very Clear it was a quotation – Sireini Apr 06 '16 at 15:29
  • 2
    You seem to not be getting the point. WTF is Duncan? Duncan is the person who answered your *other* question. Referencing him in this question without mentioning that leaves anyone reading this at a loss unless they read the other. Why should they? It has *nothing* to do with this one (even though its the same piece of code). You have two separate problems, referencing the other question confuses the issue and provides no benefit. In the other question you were having trouble adding a listener to each marker in an array and in this question you need help with *how* that listener works. – Jared Smith Apr 06 '16 at 15:36
  • @JaredSmith Never mind man – Sireini Apr 06 '16 at 15:47
  • Fine by me, but your handle is Beginnerprogrammer, and I'm trying to impart to you a valuable (arguably the *most* valuable) programming skill, how to ask for help properly. – Jared Smith Apr 06 '16 at 15:51
  • @JaredSmith Yes I know sorry I reflected my frustrations on you because I am looking for 4 hours to this godddamn problem – Sireini Apr 06 '16 at 15:55
  • Images are no longer available. – Gaʀʀʏ Jun 18 '18 at 21:31
  • This can be accomplished using an OverlayView and an "anchor" div. See [google's hello world example](https://developers.google.com/maps/documentation/javascript/examples/overlay-popup). – Gaʀʀʏ Aug 12 '19 at 14:49

1 Answers1

2

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.

Jared Smith
  • 19,721
  • 5
  • 45
  • 83