In leaflet, I have a class that extends L.GeoJSON
:
L.MyLayer = L.GeoJSON.extend
({
initialize: function ()
{
this.markers = [];
...
I redefined the pointToLayer
method to create markers for points:
pointToLayer : function(feature, latlng)
{
var marker = L.marker(lat...
...
return marker;
},
I need to store all the markers locally, so I created the markers
array.
My problem is that if I call this.
inside pointToLayer
function I obtain the Window
object instead obtaining the current instance of MyLayer
.
How can I get a reference to current MyLayer
instance inside pointToLayer
function?