Skip to content

Commit aaa159a

Browse files
committed
fix: player clusters not being clickable
1 parent b15938f commit aaa159a

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

dist/first-bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/last-bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/controls.2.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,22 @@ $(document).ready(function(){
120120
});
121121
});
122122

123-
function initControls(Map, PlayerMarkers){
123+
function initMapControl(Map){
124+
// When a layer changes. Recalculate everything and shit. Make sure nothing breaks.
125+
Map.on("baselayerchange", function (e) {
126+
127+
var mapBounds = getMapBounds(e.layer);
128+
129+
Map.setMaxBounds(mapBounds);
130+
Map.fitBounds(mapBounds);
131+
CurrentLayer = e.layer;
132+
133+
clearAllMarkers();
134+
toggleBlips();
135+
});
136+
}
137+
138+
function initPlayerMarkerControls(Map, PlayerMarkers){
124139

125140
// If they click on a clustered marker
126141
PlayerMarkers.on('clusterclick', function (a) {
@@ -149,17 +164,4 @@ function initControls(Map, PlayerMarkers){
149164

150165
Map.openPopup(html, a.layer.getLatLng());
151166
});
152-
153-
// When a layer changes. Recalculate everything and shit. Make sure nothing breaks.
154-
Map.on("baselayerchange", function (e) {
155-
156-
var mapBounds = getMapBounds(e.layer);
157-
158-
Map.setMaxBounds(mapBounds);
159-
Map.fitBounds(mapBounds);
160-
CurrentLayer = e.layer;
161-
162-
clearAllMarkers();
163-
toggleBlips();
164-
});
165167
}

js/src/map.1.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ function mapInit(elementID) {
6161
var control = new L.Control.CustomLayer(tileLayers).addTo(Map);
6262
Map.addLayer(PlayerMarkers);
6363

64-
initControls(Map, PlayerMarkers);
64+
initMapControl(Map);
65+
initPlayerMarkerControls(Map, PlayerMarkers);
6566
}
6667

6768
function createMarker(animated, draggable, objectRef, title) {
@@ -129,14 +130,18 @@ function clearAllMarkers() {
129130
}
130131
if(Map != undefined){
131132
Map.removeLayer(window.PlayerMarkers); // Remove the cluster layer
132-
133-
window.PlayerMarkers = L.markerClusterGroup({ // Re-make it fresh
134-
maxClusterRadius: 20,
135-
spiderfyOnMaxZoom: false,
136-
showCoverageOnHover: false,
137-
zoomToBoundsOnClick: false
138-
});
139-
Map.addLayer(window.PlayerMarkers); // Add it back. The clearAllMarkers() will ensure player markers are added to the new cluster layer
133+
window.PlayerMarkers = undefined;
134+
135+
setTimeout(() => {
136+
window.PlayerMarkers = L.markerClusterGroup({ // Re-make it fresh
137+
maxClusterRadius: 20,
138+
spiderfyOnMaxZoom: false,
139+
showCoverageOnHover: false,
140+
zoomToBoundsOnClick: false
141+
});
142+
Map.addLayer(window.PlayerMarkers); // Add it back. The clearAllMarkers() will ensure player markers are added to the new cluster layer
143+
initPlayerMarkerControls(Map, PlayerMarkers); //Reinitialise the event to allow clicking...
144+
}, 1000);
140145
}
141146
}
142147

js/src/socket.1.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ function updateBlip(blipObj) {
260260
}
261261

262262
function playerLeft(playerName) {
263-
if (localCache[playerName].marker != null || localCache[playerName].marker != undefined) {
263+
if (localCache[playerName] !== undefined &&
264+
(localCache[playerName].marker != null || localCache[playerName].marker != undefined)) {
264265
clearMarker(localCache[playerName].marker);
265266
delete localCache[playerName];
266267
}

0 commit comments

Comments
 (0)