google maps v3 change size of infowindow

前端 未结 6 1624
盖世英雄少女心
盖世英雄少女心 2021-02-04 14:25

I would like to set the size of an infowindow to fit the content inside. The standard infowindow is too wide I tried to use maxWidth but it doesn\'t seem to work. What is the be

6条回答
  •  一整个雨季
    2021-02-04 14:51

    Just so everyone is clear, if they stumble on this thread.

    All you need to do is set the height and width of a container in the your info window content.

    You don't need to override google classes and you don't need to get overly complicated about this.

    var contentString = '
    '+ '

    My Info Window

    '+ '

    Hello World

    '+ '
    '; var infowindow = new google.maps.InfoWindow({ content: contentString, });

    In my css I have this:

    .map-info-window {
        width:200px;
        height:200px;
    }
    

    That's it. That's all you need to do to set the width of a Google Maps InfoWindow.

提交回复
热议问题