|
@@ -459,9 +459,9 @@ export default {
|
|
|
overlays.push(polyline);
|
|
overlays.push(polyline);
|
|
|
|
|
|
|
|
const totalPoints = segmentPath.length;
|
|
const totalPoints = segmentPath.length;
|
|
|
- const stepSize = Math.max(Math.floor(totalPoints / 10), 1);
|
|
|
|
|
|
|
+ const indices = this.pickEvenlySpacedIndices(totalPoints, 8);
|
|
|
|
|
|
|
|
- for (let i = 0; i < totalPoints; i += stepSize) {
|
|
|
|
|
|
|
+ for (const i of indices) {
|
|
|
const p = segmentPath[i];
|
|
const p = segmentPath[i];
|
|
|
const lng = p && typeof p.lng === 'number' ? p.lng : (Array.isArray(p) ? Number(p[0]) : NaN);
|
|
const lng = p && typeof p.lng === 'number' ? p.lng : (Array.isArray(p) ? Number(p[0]) : NaN);
|
|
|
const lat = p && typeof p.lat === 'number' ? p.lat : (Array.isArray(p) ? Number(p[1]) : NaN);
|
|
const lat = p && typeof p.lat === 'number' ? p.lat : (Array.isArray(p) ? Number(p[1]) : NaN);
|
|
@@ -479,6 +479,23 @@ export default {
|
|
|
return overlays;
|
|
return overlays;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ pickEvenlySpacedIndices(totalPoints, count) {
|
|
|
|
|
+ const total = Math.max(Number(totalPoints) || 0, 0);
|
|
|
|
|
+ const target = Math.max(Number(count) || 0, 0);
|
|
|
|
|
+ if (total <= 0) return [];
|
|
|
|
|
+ if (target <= 0) return [];
|
|
|
|
|
+ if (target >= total) return Array.from({ length: total }, (_, i) => i);
|
|
|
|
|
+ if (target === 1) return [0];
|
|
|
|
|
+
|
|
|
|
|
+ const set = new Set();
|
|
|
|
|
+ const last = total - 1;
|
|
|
|
|
+ for (let k = 0; k < target; k += 1) {
|
|
|
|
|
+ const idx = Math.round((k * last) / (target - 1));
|
|
|
|
|
+ set.add(idx);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Array.from(set).sort((a, b) => a - b);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
buildFallbackLinePath(start, end, pointCount) {
|
|
buildFallbackLinePath(start, end, pointCount) {
|
|
|
const sLng = Number(start && start[0]);
|
|
const sLng = Number(start && start[0]);
|
|
|
const sLat = Number(start && start[1]);
|
|
const sLat = Number(start && start[1]);
|