My Leaflet map is completely functional -- so that's great. However, I noticed that my vector layer (upwards of 200 points) is slightly delayed whenever I try zooming in or out -- it almost appears to "bounce," and it's very jarring. I've tried it in Firefox and Chrome and it works the same in both browsers. I understand that this is a lot of data to render, but I'm wondering if there's anything I can do to remedy this awkward problem?
Here's the small amount of JS I've written so far (the HTML is mostly just a blank div with the id "milwaukee_map"):
// load the initial map!
var theMap = L.map('milwaukee_map', {
minZoom: 11,
maxZoom: 19
})
.setView([43.041475, -87.923975], // zoom to Milwaukee County by default
11) // set initial zoom level
// add basemap tiles
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: 'Basemap Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>; Basemap © <a href="http://cartodb.com/attributions">CARTO</a>',
subdomains: 'abcd'
}).addTo(theMap);
// load stops from carto
function getStops() {
$.getJSON('https://benjamin-schroeder.carto.com/api/v2/sql?format=GeoJSON&q=SELECT the_geom, stop_name FROM mcts_stops_feb_16', function(data){
stopsLayer = L.geoJson(data, {
pointToLayer: function(feature, latlng) {
return new L.CircleMarker(latlng, {radius: 2, fillOpacity: 0.85});
}
})
.addTo(theMap);
})
}
getStops();
Live example: https://pantherfile.uwm.edu/schro333/public/mcts_map/
Thanks!