' +
+ '

' +
+ '
' + event.description + '
';
+
+ var popup = L.popup({ maxWidth: 600 })
+ .setContent(content)
+
+ e.target.bindPopup(popup).openPopup();
+ }
+ });
+ }
// Clear old layers
if (markersCountryLayers.length > 0) {
+ console.log(`β»οΈ Clearing ${markersCountryLayers.length} old marker layers...`);
$.each(markersCountryLayers, function (key, countryLayer) {
countryLayer.clearLayers();
map.removeLayer(countryLayer);
@@ -31,41 +55,40 @@ L.custom = {
markersCountryLayers = [];
}
- // NEW: Build master cluster
+ // Build single master cluster
var allMarkers = [];
+ var totalEvents = 0;
+ var missingGeo = 0;
+
+ $.each(countryData, function (countryCode, countryEvents) {
+ console.log(`β Processing country: ${countryCode} with ${countryEvents.length} events`);
+ totalEvents += countryEvents.length;
- $.each(countryData, function (countryIso, events) {
- $.each(events, function (idx, event) {
- if (event.geoposition) {
- var coordinates = event.geoposition.split(',');
+ $.each(countryEvents, function (idx, val) {
+ if (val.geoposition) {
+ var coordinates = val.geoposition.split(',');
var lat = parseFloat(coordinates[0]);
var lng = parseFloat(coordinates[1]);
if (!isNaN(lat) && !isNaN(lng)) {
- var marker = L.marker(L.latLng(lat, lng), { id: event.id });
- marker.on('click', function (e) {
- var id = e.target.options.id;
- $.ajax({
- dataType: "json",
- url: "api/event/detail?id=" + id,
- success: function (res) {
- var ev = res.data;
- var content = '
' +
- '
' +
- '

' +
- '
' + ev.description + '
';
-
- var popup = L.popup({ maxWidth: 600 }).setContent(content);
- e.target.bindPopup(popup).openPopup();
- }
- });
- });
+ var marker = L.marker(L.latLng(lat, lng), { id: val.id });
+ marker.on('click', markerOnClick);
allMarkers.push(marker);
+ } else {
+ console.warn(`β οΈ Invalid geoposition for event ID ${val.id} in ${countryCode}:`, val.geoposition);
+ missingGeo++;
}
+ } else {
+ console.warn(`β οΈ Missing geoposition for event ID ${val.id} in ${countryCode}`);
+ missingGeo++;
}
});
});
+ console.log(`β
Total events processed: ${totalEvents}`);
+ console.log(`β
Total valid markers: ${allMarkers.length}`);
+ console.log(`β οΈ Total events missing/invalid geoposition: ${missingGeo}`);
+
var masterCluster = L.markerClusterGroup({
showCoverageOnHover: false,
maxClusterRadius: 120,
@@ -98,8 +121,8 @@ L.custom = {
markersCountryLayers.push(masterCluster);
map.addLayer(masterCluster);
- console.log('β
Markers added:', allMarkers.length);
-
+ console.log('πΊοΈ Master cluster added to map.');
+ console.log('β‘οΈ Triggering next components...');
$wt._queue("next");
};
@@ -112,6 +135,7 @@ L.custom = {
}
function getEvents(year) {
+ console.log(`π‘ Fetching events for year: ${year}...`);
$.ajax({
dataType: "json",
url: "api/event/list?year=" + year,
@@ -120,6 +144,7 @@ L.custom = {
}
var year = param('year') ? param('year') : new Date().getFullYear();
+ console.log(`π― Initial map year = ${year}`);
getEvents(year);
}
};