Closed DDroll closed 9 years ago
You can change the position for a control with the "position" option, as with a plain-old leaflet map. Example:
$scope.controls = {
scale: {position: 'topleft'}
};
I was just wondering this myself. Thanks @srthurman!
EDIT: So to do what @DDroll is asking, would you do
$scope.controls = {
layers: {position: 'topleft'}
};
and then
<leaflet controls="controls"></leaflet>
No, the controls property only contains draw
, scale
, fullscreen
, search
, custom
, and minimap
properties.
$scope.controls = { layers: {position: 'topleft'} } does not works) After little reading of directive source code i've tryed this one: defaults: { controls : { layers : {position : 'bottomleft'}}} and added 'defaults' attribute to tpl, but after that layers control just disappears without any errors in console:) . There is .setPosition metod with controls, but it is unclear, where to i should to apply it. The pot of my ideas is showing its bottom)
Try putting this in your controller. I'm making a directive, so I had luck with the following in the link
option as well.
You might not have to put it in the listener for map load, but visually that looked best (I saw the layer control jump from the original top right to the new position in other cases).
$scope.$on('leafletDirectiveMap.load', function(event, args) {
var layerPos = {
controls: {
layers: {
visible: true,
position: 'topleft',
collapsed: true,
},
}
};
leafletMapDefaults.setDefaults(layerPos, '');
});
@srthurman, great thx, visible attribute is that, what i'm lost. Now it works even without map directive load event listener. Im just define
$scope.dafaults = controls: {
layers: {
visible: true,
position: 'topleft',
collapsed: true,
},
}
and then
<leaflet defaults="defaults">
May be, it'll be valuable for solving your search control problem (and helps to avoid initial control blinking)
Is there is any way to change default layer control position? Setted through 'layers' attribute.