According to the official tutorial, I can load and show all polygons from a local geoJSON file now. I'm planning on clipping the newly created SVG layer using a custom outline path. I started with a circle as a child of clipPath that is created through Leaflet's L.circle to avoid the coordinate projection.The main code based on the official example is as follows:
// Create a circle outline
var clipcircle = new L.circle([34.5, -95.5], {radius: 300000, className: 'outline'}).addTo(map);
// Create <defs> and <clippath> elements using jquery
$('svg').prepend('<defs><clipPath id="myclip"></clipPath></defs>');
// Move the <path> element of clipcircle from <g> to <clipPath>
$('path.outline').appendTo('#myclip');
// Add CSS clip-path attribute to all svg groups
$('g').css('clip-path', 'url(#myclip)');
// load and show polygons from geoJSON
var geojson = L.geoJSON(statesData, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
map.fitBounds(geojson.getBounds());
The code works as expected however the clipPath is not working. Only the area inner the circle is expected to be shown, but all polygons except the circle are still be shown on the page, illustrated as the following images: