在谷歌地图php api中更改InfoWindow的宽度

时间:2013-04-28 19:45:32

标签: javascript php google-maps

我正在使用Google Maps PHP API,我需要更改弹出的“infoWindow”的宽度,然后点击Markers,我尝试了几种方法,但我失败了。 我正在使用从互联网上下载的api,我正在使用函数$ MAP_OBJECT-> addMarkerByCoords()。

function getCreateMarkerJS() {
    $_output = "
       function createMarker(map, point, title, html, icon, icon_shadow, sidebar_id, openers){
            var marker_options = {
                position: point,
                map: map,
                title: title};  
            if(icon!=''){marker_options.icon = icon;}
            if(icon_shadow!=''){marker_options.shadow = icon_shadow;}

            //create marker
            var new_marker = new google.maps.Marker(marker_options);
            if(html!=''){
                ".(($this->info_window)?"




                google.maps.event.addListener(new_marker, '".$this->window_trigger."', function() {
                    infowindow.close(); 
                    infowindow.setContent(html);
                    infowindow.open(map,new_marker);
                });

                if(openers != ''&&!isEmpty(openers)){
                   for(var i in openers){
                     var opener = document.getElementById(openers[i]);
                     opener.on".$this->window_trigger." = function() { 

                        infowindow.close();
                        infowindow.setContent(html);
                        infowindow.open(map,new_marker); 

                        return false;                           
                     };
                   }
                }
                ":"")."
                if(sidebar_id != ''){
                    var sidebar = document.getElementById(sidebar_id);
                    if(sidebar!=null && sidebar!=undefined && title!=null && title!=''){
                        var newlink = document.createElement('a');
                        ".(($this->info_window)?"
                        newlink.onclick=function(){infowindow.open(map,new_marker); return false};
                        ":"
                        newlink.onclick=function(){map.setCenter(point); return false};
                        ")."
                        newlink.innerHTML = title;
                        sidebar.appendChild(newlink);
                    }
                }
            }
            return new_marker;  
        }
    ";
    return $_output;
}

1 个答案:

答案 0 :(得分:0)

InfoWindow对象有一个方法setOptions({opts}),可让您更改InfoWindowOptions。您可以使用它来设置InfoWindow的maxWidth。

InfoWinodow的实际宽度由内容的宽度决定,更改内容的宽度将比InfoWindow更改。