olwidget
olwidget copied to clipboard
mapDivStyle and map_div_style width/height only work with px not %
I'd like to use a default of 100% for width and height but that causes the view to fail.
OLWIDGET_DEFAULT_OPTIONS = { #"map_div_style": {"width": "100%", "height": "100%"}}
Any ideas on how to fix this?
Thanks.
This may not be elegant, but I've solved the problem I had as follows:
<script type="text/javascript">
var div = OpenLayers.Util.getElement("map");
div.style.height = window.innerHeight + "px";
olwidget_map.updateSize();
var extent = new OpenLayers.Bounds();
for (var i = 0; i < olwidget_map.vectorLayers.length; i++) {
var vl = olwidget_map.vectorLayers[i];
if (vl.opts.cluster) {
for (var j = 0; j < vl.features.length; j++) {
for (var k = 0; k < vl.features[j].cluster.length; k++) {
extent.extend(vl.features[j].cluster[k].geometry.getBounds());
}
}
} else {
extent.extend(vl.getDataExtent());
}
}
if (!extent.equals(new OpenLayers.Bounds())) {
olwidget_map.zoomToExtent(extent);
olwidget_map.zoomTo(Math.min(olwidget_map.getZoom(), olwidget_map.opts.zoomToDataExtentMin));
}
</script>