Marin Leontenko
Marin Leontenko

Reputation: 771

Position of icon in Leaflet Easy Button

I'm using Leaflet easy button on my Leaflet map:

<!-- Load LeafletEasyButton -->  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-easybutton@2/src/easy-button.css">
<script src="https://cdn.jsdelivr.net/npm/leaflet-easybutton@2/src/easy-button.js"></script>

I'm also using Google Material icons:

<!-- Load Google Material Icons -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

The goal is to create a custom button on my leaflet map like this:

L.easyButton('<i class="material-icons" style="font-size:18px;">gps_fixed</i>', function(){
    locateMe();
}, {position: 'bottomright'}).addTo(map);

It works, but icon in my custom button is positioned above button center:

enter image description here

How can I center the icon?

Upvotes: 3

Views: 3060

Answers (1)

Ahmadreza Paripaykar
Ahmadreza Paripaykar

Reputation: 26

you can use left/top in css code:

 .widget-code {
    display: block;
    height: 18px;
    left: 6px;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 6px;
    width: 18px;
}

Upvotes: 1

Related Questions