Leaflet: simple plugin beta 2
by Leo
HTML
<script src="//rawgit.com/gorshkov-leonid/leaflet-shape-coordinates-js/master/leaflet-shape-coordinates.js"></script>
<body>
<button type="btn1" id="addListenerButton">Add listener</button>
<button type="btn2" id="removeListenerButton">Remove listener</button>
<div id="mapWrapper">
<div id="map" ></div>
</div>
</body>
CSS
html, body, #map {
margin: 0;
width: 600px;
height: 500px;
}
#mapWrapper
{
padding: 10px;
margin: 10px;
width: 100%;
height: 100%;
}
JavaScript
var map = new L.Map('map', {center: new L.LatLng(45.5 + 0.003, -73.5 + 0.003), zoom: 16});
var simpleLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
var marker = L.marker([45.5, -73.5], {shapeCoordinates: [7, 7, 7, 18, 18, 18, 18, 7]});
var listener = function (events)
{
console.log('!!!!!!!!!!!!!!!!! ');
}
document.getElementById('addListenerButton').addEventListener('click', function ()
{
marker.on('click', listener);
});
document.getElementById('removeListenerButton').addEventListener('click', function ()
{
marker.off('click', listener);
});
map.addLayer(marker);