diff --git a/src/Map.vue b/src/Map.vue
index 7a038280..bc884e14 100644
--- a/src/Map.vue
+++ b/src/Map.vue
@@ -695,6 +695,20 @@
location_on
+
+
+
+
+
+ Show Accurate Range
+ NOTE: Can be slow
+
+
+ approval
+
+
= 1580) {
+ break;
+ } else {
+ lastLatLng = new LatLng(x1, y1);
+ }
+ }
+
+ return lastLatLng;
+}
+
+/**
+ * Calculates a series of points indicating the max mortaring distance all around the mortar
+ * This also accounts for the height difference
+ *
+ * @param {LatLng} mPos - mortar position
+ * @param {number} bearing - bearing
+ * @param {number} mVel - mortar shell velocity
+ * @param {boolean} [useNatoMils] - use regular Milliradians or NATO Milliradians (Squad uses NATO mils)
+ * @param {SquadMap} [SquadMap] - use regular Milliradians or NATO Milliradians (Squad uses NATO mils)
+ * @returns {LatLng[]} - The coordniates forming a polygon
+ */
+export function getMaxMortar360Distance(mPos, mVel, squadMap, useNatoMils = true) {
+ const latLngs = [];
+
+ for (let bearing = 0; bearing < 360; bearing += 18) {
+ const latLng = getMaxMortarDistance(mPos, bearing, mVel, squadMap, useNatoMils);
+ if (!latLng) {
+ console.warn("invalid latlng");
+ }
+ latLngs.push(latLng);
+ }
+
+ return latLngs;
+}
+
/**
* Get available mortar types for Squad
*
diff --git a/src/assets/marker/MarkerHolder.js b/src/assets/marker/MarkerHolder.js
index e7807295..46bbdbf7 100644
--- a/src/assets/marker/MarkerHolder.js
+++ b/src/assets/marker/MarkerHolder.js
@@ -90,7 +90,13 @@ export default class MarkerHolder {
*/
_moveAttachments(latlng) {
this._attachments.forEach((a) => {
- a.setLatLng(latlng);
+ try {
+ a.setLatLng(latlng);
+ } catch (error) {
+ // This error happens because you can't call .setLatLng() on the polygram attachment
+ // Feel free to find a better way to handle this error
+ console.log("this is fine");
+ }
});
}
diff --git a/src/assets/marker/pin/MortarPin.js b/src/assets/marker/pin/MortarPin.js
index ee292c5f..ae2fbe78 100644
--- a/src/assets/marker/pin/MortarPin.js
+++ b/src/assets/marker/pin/MortarPin.js
@@ -1,4 +1,4 @@
-import { Circle } from "leaflet";
+import { Circle, Polygon } from "leaflet";
import PinHolder from "./PinHolder";
import { MIN_DISTANCE, SQUAD_MAX_DISTANCE } from "../../Vars";
@@ -37,6 +37,16 @@ export default class MortarPin extends PinHolder {
}
}
+ /**
+ * This postions in which the mortar are actually able to hit
+ * @param {LatLng[]} latlngs
+ */
+ setMaxRangePolygon(latlngs) {
+ if (this.maxRangePolygon) {
+ this.maxRangePolygon.setLatLngs(latlngs);
+ }
+ }
+
/**
* Creates min and max range circles for mortar marker
*/
@@ -64,6 +74,20 @@ export default class MortarPin extends PinHolder {
clickable: false, // legacy support
});
- this._attachments = [this.minRangeCircle, this.maxRangeCircle];
+ /**
+ * This shows the actual range in which the mortar are able to hit. This accounts for height differences
+ */
+ this.maxRangePolygon = new Polygon(this.pos, {
+ draggable: "false",
+ radius: this.maxDistance,
+ color: "red",
+ fillOpacity: 0.1,
+ fillColor: this.color,
+ dashArray: "5, 5",
+ interactive: false,
+ clickable: false, // legacy support
+ });
+
+ this._attachments = [this.minRangeCircle, this.maxRangeCircle, this.maxRangePolygon];
}
}