Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circlemarkers do not update #153

Open
chrisluedtke opened this issue Nov 15, 2019 · 1 comment
Open

circlemarkers do not update #153

chrisluedtke opened this issue Nov 15, 2019 · 1 comment

Comments

@chrisluedtke
Copy link

When mapping many points as circleMarkers, my features fail to update. I suspect this is because the circleMarkers can't be identified or associated to the GeoJSON features. The error in the console is TypeError: Cannot read property 'hasOwnProperty' of undefined.

Example data:

[{
    "type": "Feature", 
    "properties": {
        "color": "#522398", 
        "rn": "503"
    }, 
    "geometry": {
        "type": "Point", 
        "coordinates": [-87.68962, 42.07125]
    }
}, {
    "type": "Feature", 
    "properties": {
        "color": "#522398", 
        "rn": "515"
    }, 
    "geometry": {
        "type": "Point", 
        "coordinates": [-87.68551, 42.0638]
    }
}]

Javascript:

var mymap = L.map('map').setView([41.8759, -87.6251], 11);

var realtime = L.realtime({
        url: 'http://localhost:5000/get_trains',
        crossOrigin: true,
        type: 'json'
    }, {
        interval: 5 * 1000,
        pointToLayer: function (feature, latlng) {
            return L.circleMarker(latlng, {
                // Stroke properties
                color: feature.properties.color,
                opacity: 0.75,
                weight: 2,

                // Fill properties
                fillColor: feature.properties.color,
                fillOpacity: 0.5,

                radius: 5
            })
        },
        getFeatureId: function(feature) {
            return feature.properties.rn;
        },
    }).addTo(mymap);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mymap);

realtime.on('update', function() {});
@perliedman
Copy link
Owner

Hi, could you please either provide a running example illustrating the issue, or at least a stacktrace showing where the error occurs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants