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/
To enable it, use the map's zoomSnap option. The zoomSnap option has a default value of 1 (which means that the zoom level of the map can be 0 , 1 , 2 , and so on). If you set the value of zoomSnap to 0.5 , the valid zoom levels of the map will be 0 , 0.5 , 1 , 1.5 , 2 , and so on.
Leaflet, unlike Google Maps and other all-in-one solutions, is just a JavaScript library. It's free to use, but doesn't provide map imagery on its own — you have to choose a tile service to combine with it.
Used to load and display tile layers on the map, implements ILayer interface.
Leaflet is designed with simplicity, performance and usability in mind. It works efficiently across all major desktop and mobile platforms, can be extended with lots of plugins, has a beautiful, easy to use and well-documented API and a simple, readable source code that is a joy to contribute to.
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
Currently you can use:
var map = L.map('map', { zoomControl: true }); map.zoomControl.setPosition('topright');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With