It's something that I have very rarely done - adding properties to a Leaflet marker.
I was reading this page which says that we should
customMarker = L.Marker.extend({
options: {
name: '',
type: ''
}
});
var marker = new customMarker([28.63278, 77.21972],{
clickable: true,
name: 'Connaught Place',
type: 'Neighbourhood'
}).addTo(map);
I see from some old code that I have simply
let marker = L.marker(markerLatLng, {
name: 'Connaught Place',
type: 'Neighbourhood'
Since this works, it seems like Leaflet is intelligent enough to treat any non-Leaflet properties as extending the L.Marker
class.
Is there a "correct" way (with a technical reason for it being correct)?