leaflet-realtime icon indicating copy to clipboard operation
leaflet-realtime copied to clipboard

Cannot read property 'layerPointToLatLng' of undefined when creating a circle

Open ewrt101 opened this issue 4 years ago • 0 comments

when creating a circle in pointToLayer() i get the error Cannot read property 'layerPointToLatLng' of undefined when creating a circle. this does not happen with circleMarker()

this is my code

//map setup
var mymap = L.map('mapid'),
    realtime = L.realtime({
        url: 'http://localhost:3000',
        crossOrigin: true,
        type: 'json'
    }, {
        interval: 3 * 1000,
        onEachFeature(f, l){
            l.bindPopup(function() {
                return '<h3>' + f.properties.id + '</h3>';
            });
        },
        
        pointToLayer: function (feature, latlng) {
            return L.circle(latlng, {
                color: 'gray',
                fillColor: '#545454',
                fillOpacity: 0.5,
                radius: 75
            })
        }
        
        
    }).addTo(mymap);

//select tile provider
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { // other version of map https://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png
    attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
    maxZoom: 20,
}).addTo(mymap);

realtime.once('update', function() {
    mymap.fitBounds(realtime.getBounds(), {maxZoom: 3});
});

ewrt101 avatar Nov 11 '20 00:11 ewrt101