✨ MAJOR FEATURES: • Auto-zoom intelligence với smart bounds fitting • Enhanced 3D GPS markers với pulsing effects • Professional route display với 6-layer rendering • Status-based parking icons với availability indicators • Production-ready build optimizations 🗺️ AUTO-ZOOM FEATURES: • Smart bounds fitting cho GPS + selected parking • Adaptive padding (50px) cho visual balance • Max zoom control (level 16) để tránh quá gần • Dynamic centering khi không có selection 🎨 ENHANCED VISUALS: • 3D GPS marker với multi-layer pulse effects • Advanced parking icons với status colors • Selection highlighting với animation • Dimming system cho non-selected items 🛣️ ROUTE SYSTEM: • OpenRouteService API integration • Multi-layer route rendering (glow, shadow, main, animated) • Real-time distance & duration calculation • Visual route info trong popup 📱 PRODUCTION READY: • SSR safe với dynamic imports • Build errors resolved • Global deployment via Vercel • Optimized performance 🌍 DEPLOYMENT: • Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app • Bundle size: 22.8 kB optimized • Global CDN distribution • HTTPS enabled 💾 VERSION CONTROL: • MapView-v2.0.tsx backup created • MAPVIEW_VERSIONS.md documentation • Full version history tracking
69 lines
2.4 KiB
JavaScript
69 lines
2.4 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = closestIndexTo;
|
|
var _index = _interopRequireDefault(require("../toDate/index.js"));
|
|
var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
|
|
/**
|
|
* @name closestIndexTo
|
|
* @category Common Helpers
|
|
* @summary Return an index of the closest date from the array comparing to the given date.
|
|
*
|
|
* @description
|
|
* Return an index of the closest date from the array comparing to the given date.
|
|
*
|
|
* @param {Date | Number} dateToCompare - the date to compare with
|
|
* @param {Array<Date> | Array<number>} datesArray - the array to search
|
|
* @returns {Number | undefined} an index of the date closest to the given date or undefined if no valid value is given
|
|
* @throws {TypeError} 2 arguments required
|
|
*
|
|
* @example
|
|
* // Which date is closer to 6 September 2015?
|
|
* const dateToCompare = new Date(2015, 8, 6)
|
|
* const datesArray = [
|
|
* new Date(2015, 0, 1),
|
|
* new Date(2016, 0, 1),
|
|
* new Date(2017, 0, 1)
|
|
* ]
|
|
* const result = closestIndexTo(dateToCompare, datesArray)
|
|
* //=> 1
|
|
*/
|
|
function closestIndexTo(dirtyDateToCompare, dirtyDatesArray) {
|
|
(0, _index2.default)(2, arguments);
|
|
var dateToCompare = (0, _index.default)(dirtyDateToCompare);
|
|
if (isNaN(Number(dateToCompare))) return NaN;
|
|
var timeToCompare = dateToCompare.getTime();
|
|
var datesArray;
|
|
// `dirtyDatesArray` is undefined or null
|
|
if (dirtyDatesArray == null) {
|
|
datesArray = [];
|
|
|
|
// `dirtyDatesArray` is Array, Set or Map, or object with custom `forEach` method
|
|
} else if (typeof dirtyDatesArray.forEach === 'function') {
|
|
datesArray = dirtyDatesArray;
|
|
|
|
// If `dirtyDatesArray` is Array-like Object, convert to Array. Otherwise, make it empty Array
|
|
} else {
|
|
datesArray = Array.prototype.slice.call(dirtyDatesArray);
|
|
}
|
|
var result;
|
|
var minDistance;
|
|
datesArray.forEach(function (dirtyDate, index) {
|
|
var currentDate = (0, _index.default)(dirtyDate);
|
|
if (isNaN(Number(currentDate))) {
|
|
result = NaN;
|
|
minDistance = NaN;
|
|
return;
|
|
}
|
|
var distance = Math.abs(timeToCompare - currentDate.getTime());
|
|
if (result == null || distance < Number(minDistance)) {
|
|
result = index;
|
|
minDistance = distance;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
module.exports = exports.default; |