Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
136
rated 0 times [  137] [ 1]  / answers: 1 / hits: 57526  / 10 Years ago, tue, april 8, 2014, 12:00:00

I am trying to customize zoom control (+/-), so it should appear in the right side like Google maps (https://www.google.com/maps/)



I tried to add float:right; but it didn't work.



From the CSS file :



/* zoom control */

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px;
}
.leaflet-control-zoom-out {
font-size: 20px;
}

.leaflet-touch .leaflet-control-zoom-in {
font-size: 22px;
}
.leaflet-touch .leaflet-control-zoom-out {
font-size: 24px;
}


http://jsfiddle.net/hsy7v/1/


More From » css

 Answers
61

Your zoom in/out controls are wrapped with absolutely positioned element with left:0 (due to .leaflet-left class), so float:left wouldn't help, you could align it to right by overriding left:0 by right:0, or changing .leaflet-left class to .leaflet-right



But more correct way would be to use provided api.



//disable zoomControl when initializing map (which is topleft by default)
var map = L.map(map, {
zoomControl: false
//... other options
});

//add zoom control with your options
L.control.zoom({
position:'topright'
}).addTo(map);


see updated fiddle



api reference for the library you use can be found here


[#71568] Saturday, April 5, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaceyr

Total Points: 510
Total Questions: 97
Total Answers: 116

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
kaceyr questions
;