Skip to content

Commit

Permalink
filter out items outside of map bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Nov 9, 2023
1 parent 0a7d770 commit a6e7559
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ function Map() {
layerControl.addOverlay(layer, layerOptions.layerName, layerOptions);
};

const positionIsInBounds = (position) => {
return bounds.contains(pos(position));
};

let markerBounds = {
'TL': {x:Number.MAX_SAFE_INTEGER, z:Number.MIN_SAFE_INTEGER},
'BR': {x:Number.MIN_SAFE_INTEGER, z:Number.MAX_SAFE_INTEGER}
Expand All @@ -725,6 +729,9 @@ function Map() {
bloodhound: L.layerGroup(),
}
for (const spawn of mapData.spawns) {
if (!positionIsInBounds(spawn.position)) {
continue;
}
let spawnType = '';
let bosses = [];

Expand Down Expand Up @@ -840,6 +847,9 @@ function Map() {
scav: 100,
};
for (const extract of mapData.extracts) {
if (!positionIsInBounds(extract.position)) {
continue;
}
const colorMap = {
scav: '#ff7800',
pmc: '#00e599',
Expand Down Expand Up @@ -902,6 +912,10 @@ function Map() {
if (!key) {
continue;
}

if (!positionIsInBounds(lock.position)) {
continue;
}

checkMarkerBounds(lock.position, markerBounds);
const lockIcon = L.icon({
Expand Down Expand Up @@ -966,6 +980,9 @@ function Map() {
continue;
}
for (const position of loc.positions) {
if (!positionIsInBounds(position)) {
continue;
}
const questItemIcon = L.icon({
iconUrl: `${process.env.PUBLIC_URL}/maps/interactive/quest_item.png`,
iconSize: [24, 24],
Expand Down Expand Up @@ -999,6 +1016,9 @@ function Map() {
if (zone.map.id !== mapData.id) {
continue;
}
if (!positionIsInBounds(zone.position)) {
continue;
}
const rect = L.polygon(outlineToPoly(zone.outline), {color: '#e5e200', weight: 1, className: 'not-shown'});
const zoneIcon = L.icon({
iconUrl: `${process.env.PUBLIC_URL}/maps/interactive/quest_objective.png`,
Expand Down Expand Up @@ -1045,6 +1065,9 @@ function Map() {
if (mapData.switches.length > 0) {
const switches = L.layerGroup();
for (const sw of mapData.switches) {
if (!positionIsInBounds(sw.position)) {
continue;
}
const switchIcon = L.icon({
iconUrl: `${process.env.PUBLIC_URL}/maps/interactive/switch.png`,
iconSize: [24, 24],
Expand Down Expand Up @@ -1120,6 +1143,9 @@ function Map() {
const containerLayers = {};
const containerNames = {};
for (const containerPosition of mapData.lootContainers) {
if (!positionIsInBounds(containerPosition.position)) {
continue;
}
const containerIcon = L.icon({
iconUrl: `${process.env.PUBLIC_URL}/maps/interactive/${images[`container_${containerPosition.lootContainer.normalizedName}`]}.png`,
iconSize: [24, 24],
Expand Down Expand Up @@ -1155,6 +1181,9 @@ function Map() {
if (mapData.hazards.length > 0) {
const hazardLayers = {};
for (const hazard of mapData.hazards) {
if (!positionIsInBounds(hazard.position)) {
continue;
}
const rect = L.polygon(outlineToPoly(hazard.outline), {color: '#ff0000', weight: 1, className: 'not-shown'});
const hazardIcon = L.icon({
iconUrl: `${process.env.PUBLIC_URL}/maps/interactive/hazard.png`,
Expand Down Expand Up @@ -1199,6 +1228,9 @@ function Map() {
if (mapData.stationaryWeapons.length > 0) {
const stationaryWeapons = L.layerGroup();
for (const weaponPosition of mapData.stationaryWeapons) {
if (!positionIsInBounds(weaponPosition.position)) {
continue;
}
const weaponIcon = L.icon({
iconUrl: `${process.env.PUBLIC_URL}/maps/interactive/stationarygun.png`,
iconSize: [24, 24],
Expand Down

0 comments on commit a6e7559

Please sign in to comment.