A.Andre A.Andre - 29 days ago 10
Javascript Question

GeoJson feature property from string to integer

I have a markercluster initialized as so:

var geoJsonLayer = L.geoJSON(storer, {
pointToLayer: function (geoJsonPoint, latlng) {
return L.circleMarker(latlng);
onEachFeature: onEachFeature,
style: style,
fillcolor: style


Each feature has a property called Year, showing when the observations were recorded. However, this property is a string and not an integer. How would I go about changing this property into an integer?

Answer Source

In function onEachFeature overwrite a feature, e.g:

onEachFeature: function(feature, layer) {
  feature.properties.example = parseInt(feature.properties.example)