I am trying to get the locator plugin to activate when clicking on the marker icon in my html sidebar. I would like it to use the locator function when clicked without adding the locator plugin to the map. This code below adds the fa-map-marker icon to the sidebar and, when you click on the icon, it adds the locator control to the leaflet map. Once you click on the added icon, it uses the L.control.locate function. Instead of adding the locator plugin to my map, can I somehow use the locator's function through onclick? End result will allow the user to directly get his location by clicking the fa-map-marker icon.
Sidebar-v2: https://github.com/Turbo87/sidebar-v2
L.control.locate: https://github.com/domoritz/leaflet-locatecontrol
<div class="sidebar-tabs">
<ul role="tablist">
<li>
<a
title="Geolocate" role="tab" target="_blank" onClick="L.control.locate().addTo(map);" <i class="fa fa-map-marker"> </i>
</a>
</li>
</ul>
</div>