Google maps infobox - maxWidth

I am facing the strange behavior of the Google Maps infobox. I adjusted maxWidth to 0 to allow the info box size to adjust the content, but I always get the 236px info box.

var infobox = new InfoBox({
    maxWidth:0
    ,pixelOffset: new google.maps.Size(5, 10)
    ,isHidden:false
    ,closeBoxURL:""
    ,pane: "floatPane"
    ,enableEventPropagation: false
    ,Zindex: null
});

If I adjust the width of the infobox in the css file as shown below, I get the same size in each infobox.

.infobox {width: 500px;}

What am I doing wrong? Any idea how to solve this?

+5
source share
3 answers

You can also use the object boxStyleinInfoBoxOptions

boxStyle: {
      whiteSpace: "nowrap"
}
+2
source

, , . jQuery , . , API .

getInfoBoxDimensions: function( content ) {
    var sensor = $("<div>").html(content);
    $(sensor).appendTo("body").css({"position" : "absolute", "left" : "-900px"});
    var width = $(sensor).width();
    var height = $(sensor).height();
    $(sensor).remove();
    return new Array(width, height);
},

html :

var infoBoxDimensions = getInfoBoxDimensions(info_box_html);

infoBox, :

var ib = new InfoBox({
     content : info_box_html,
     boxStyle : {
          width : infoBoxDimensions[0] + "px",
          height : infoBoxDimensions[1] + "px"
     },
     ....
     ....
});

info_box_html " ". 100%, , .

,

+1

, "" , :

google auto , JS Google:

.gm-style-iw {
    width: auto !important;
    height: auto !important;
    div {
        width: auto !important;
        height: auto !important;
    }
}
0

All Articles