React: Leaflet EasyButton

This entry is part 3 of 9 in the series React: Leaflet
(Last Updated On: )

In this tutorial I will demonstrate how to add a easy button to your leaflet map. This will just be a basic example. For more information refer to the documentation.

Before We Begin:

Node Package Install:

  1. npm install leaflet-easybutton --save

Edit app/home/leaflet/js/map.jsx:

  1. //Add the leaflet easybutton package
  2. require("leaflet-easybutton");
  3. require("leaflet-easybutton/src/easy-button.css");
  4.  
  5. //Somehwere on your page add the following.
  6.  
  7.  
  8. //Check out https://github.com/CliffCloud/Leaflet.EasyButton for more uses
  9. L.easyButton("<div id="tag" class="glyphicon glyphicon-tag" />", function(btn, map) {
  10. map.setView([42.3748204,-71.1161913],16);
  11. }, { position: "topleft"}).addTo(this.map);
  12.  
Series Navigation<< React: Leaflet ModalReact: Leaflet html Controls >>