简体   繁体   中英

google map infobox position

I've been googling that question for some time and all I got is headache. I add google marker with infobox on my google map, but the infobox is located lower than marker, how ever I would really appreciate it to be over the marker. Does anyone know how to do it?

And please don't gove some links to somewhere, I was seeing it for a loooong time today. Thank you in advance.

set the alignBottom -property of the infoBox to true (default is false ). For further adjustments of the position use the pixelOffset -property of the infoBox

By default the infoBox will point the bottom left of the marker. You can simply do this:

var ib= new InfoBox({
    ....//other properties,
    pixelOffset: new google.maps.Size(-25, 0) //where your marker's height is 25px
});
infobox = new InfoBox({
         content: document.getElementById("infobox"),
         disableAutoPan: false,
         maxWidth: 150,
         pixelOffset: new google.maps.Size(-140, -45),
         zIndex: null,
         boxStyle: {
            background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') 0% 100% no-repeat",
            opacity: 0.75,
            width: "280px"
        },
        infoBoxClearance: new google.maps.Size(1, 1),
        alignBottom: true
    });


#infobox {
    border:2px solid black;
    margin-bottom: 8px;
    background:#333;
    color:#FFF;
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
    padding: .5em 1em;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;
    text-shadow:0 -1px #000000;
    -webkit-box-shadow: 0 0  8px #000;
    box-shadow: 0 0 8px #000;
}

// Load the customized arrow from local

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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