I'm using react-leftlet to display markers in many counties. As you can see I'm mapping about 53K markers. The problem is that after I render these markers the webpage is practically unusable and it often freezes. Is there a way around this leaflet limitation? Is there a better way to display this many markers? Im using GeoJson as a data source. This is how I'm rendering these points:
<GeoJSON
key={_.uniqueId()}
data= {this.props.countrySelected.geojson}
pointToLayer={this.pointToLayer.bind(this)}
></GeoJSON>
Here is the pointToLayer Function:
pointToLayer = (feature, latlng) => {
// console.log(feature.properties);
return L.circleMarker(latlng, {
color: this.getStyle(feature.properties.speed_connectivity, feature.properties.type_connectivity),
fillColor: this.getStyle(feature.properties.speed_connectivity),
fillOpacity: .6,
radius: 1
}).bindPopup(popUpString(feature.properties)); // Change marker to circle
}
Update using heat map:
<HeatmapLayer
fitBoundsOnLoad
fitBoundsOnUpdate
points={this.props.countrySelected.geojson}
longitudeExtractor={m => m.geometry.coordinates[1]}
latitudeExtractor={m => m.geometry.coordinates[1]}
intensityExtractor={m => parseFloat(m.properties.speed_connectivity)}
/>