I have a very simple question. I'm using EasyButton plugin of leaflet. But I can not change its location on map. For example how can I move the button to top right corner?

Here is my code:

   var toggle = L.easyButton ({
states: [{
stateName: 'remove-legend',
icon: '<span>masquer la légende</span>',
title: 'masquer la légende',
onClick: function(control) {
}, {
icon:'<span>voir la légende</span>',
stateName: 'add-legend',
  title: 'voir la légende' ,
  onClick: function(control) {

Simply add the position property, just like for other Leaflet controls:

var toggle = L.easyButton ({
  position: 'topright', // topleft, topright, bottomleft, bottomright
  //your code here
| improve this answer | |
  • Thank you! But, one more thing: I want to put it below the layer control pane (that small square showing layers), how to do that? @afalciano – Gamze Mar 27 '17 at 10:06
  • Add the layer control to map first, then the easyButton one. If they have the same position, their relative position depends by the order of loading. – Antonio Falciano Mar 27 '17 at 10:10
  • @Gamze If my answer was useful, please consider also to vote it up. Thanks! – Antonio Falciano Mar 27 '17 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.