The following is producing the error in the question when I check in console.log and it breaks it
var map = L.map('map').setView([0, 0], 2);
<?php
$classesForCountries = [];
if (have_posts()) : while (have_posts()) : the_post();
$classesForCountries[ get_field('country') ] += get_field('year') + ' ';
endwhile; endif;
?>
// Now this should look something like {"Australia": "2006 2010 "}
var classNameMap = <?php echo JSON_encode($classesForCountries); ?>;
geojson = L.geoJson(statesData, {
style: function(feature) {
// Here is where we got the issue
var classes = classNameMap[feature.properties.sovereignt];
if (classes) {
return {className: classes};
}
},
}).addTo(map);
UPDATE
by looking at console.log, it points me to a line in the library:
...t.replace(/^\s+|\s+$/g,"")},splitWords:function(t){return o.Util.trim(t).split(/\s+/)}...