Open 1Map opened 3 months ago
It's just a matter of CSS...
.ol-control.ol-bar .ol-option-bar .ol-control {
display: block;
}
Thanks, but this does not work on my side. Can you please share a sandbox link which shows how this is done?
Please note. I am not talking about the sub-bar being cut off. I am talking about buttons in the main bar. Have for example a horizontal bar with a lot of buttons. Now on the mobile device the user must then be able to drag the bar (left/right) to see the rest of the buttons (overflow-x)
And when the bar is vertically, the same: User drag the bar up down to see the rest of the buttons (overflow-y)
Ok, in the codepen it also shows outside the screen and I am unable to scroll horizontally. Test your codepen with the following code (Note that I added a lot of ZoomToExtent Control Buttons just to mimic the problem of overflowing - The same can be tested with a vertical bar where the user needs to scroll up/down):
var map = new ol.Map({
target: 'map',
view: new ol.View({
center: [274770, 6243929],
zoom: 3
}),
layers: [ new ol.layer.Geoportail('GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2') ]
});
var vector = new ol.layer.Vector({
name: "Countries",
source: new ol.source.Vector,
})
map.addLayer(vector)
// Main control bar
var mainbar = new ol.control.Bar();
map.addControl(mainbar);
/* Nested toobar with one control activated at once */
var nested = new ol.control.Bar ({ toggleOne: true, group:true });
mainbar.addControl (nested);
// Add selection tool (a toggle control with a select interaction)
var selectCtrl = new ol.control.Toggle({
html: '<i class="fa fa-hand-pointer-o"></i>',
className: "select",
title: "Select",
interaction: new ol.interaction.Select (),
active:true,
onToggle: function(active) {
$("#info").text("Select is "+(active?"activated":"deactivated"));
}
});
nested.addControl(selectCtrl);
// Add editing tools
var pedit = new ol.control.Toggle({
html: '<i class="fa fa-map-marker" ></i>',
className: "edit",
title: 'Point',
interaction: new ol.interaction.Draw({
type: 'Point',
source: vector.getSource()
}),
onToggle: function(active) {
$("#info").text("Edition is "+(active?"activated":"deactivated"));
}
});
nested.addControl ( pedit );
/* Standard Controls */
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.ZoomToExtent({ extent: [ 265971,6243397 , 273148,6250665 ] }));
mainbar.addControl (new ol.control.Rotate());
mainbar.addControl (new ol.control.FullScreen());
I got it fixed by changing to:
.ol-control.ol-bar {
left: calc(50% + 1.5rem);
max-width: calc(100% - 9rem);
max-height: calc(100% - 9rem);
overflow: auto;
}
This actually is the correct way:
.ol-overlaycontainer-stopevent > .ol-control.ol-bar {
max-width: calc(100% - 12.85rem);
max-height: unset;
overflow-x: auto;
overflow-y: hidden;
}
.ol-overlaycontainer-stopevent > .ol-control.ol-bar.ol-left,
.ol-overlaycontainer-stopevent > .ol-control.ol-bar.ol-right {
max-width: unset;
max-height: calc(100% - 12.85rem);
overflow-x: hidden;
overflow-y: auto;
}
How can I make the ol.control.Bar scrollable (Horizontal or Vertical) if on small screens, like mobile devices?