[GIS] Adding Clickable Button on Leaflet Map

cssjavascriptleaflet

I am trying to add a clickable button on Leaflet map. Right now using this:

<ion-content padding scrollbar-y-auto>   
  <div id="map" style="width: 100%; height: 100%"></div>
  <div class="leaflet-bottom leaflet-right">
    <button ion-button class="button-action" (click)="Action()"  block>Action!>/button>
  </div>
</ion-content>

CSS:

page-map {
  @font-face {
    font-family: 'Minecraft';
    src: url('../assets/Minecraft.ttf')
    }   
    .button-action{
      height: 40px;
      width: 200px;
      text-decoration: none;
      text-align: center;
      color: white;
      background: url('https://i.hizliresim.com/QpVGbg.png') no-repeat;
      font-family: Minecraft;
      line-height: 26px;
      padding-top: 6px;
  }   
  .button-action:hover{
      background: url('https://i.hizliresim.com/a1zraR.png') no-repeat;
  }    
}

This is what I got:

enter image description here

I can't click the button it's like a picture also hover option is not working too.

class="leaflet-bottom leaflet-right"> killing the button, or somehow button goes behind map so I can't click

Best Answer

Have you tried L.EasyButton? It's quick and easy, although the buttons can contain only icons out of the box. There's plenty of useful examples and demos on site.

If that doesn't suit your needs, you'll have to extend Leaflets L.control class. Let me know and I'll try to work up an example using L.Control