![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-acomp/js/LocationView.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ACore = _interopRequireWildcard(require("../ACore")); var _utils = require("./utils"); var _DomSignal = _interopRequireDefault(require("absol/src/HTML5/DomSignal")); var _stringGenerate = require("absol/src/String/stringGenerate"); var _Color = _interopRequireDefault(require("absol/src/Color/Color")); var _MarkerClusterer = _interopRequireDefault(require("./MarkerClusterer")); var _LocationPicker = require("./LocationPicker"); var MARKER_RADIUS = 10; var MARKER_BORDER_COLOR = '#4945C8'; function generateColor(id) { id = id + ''; var rgb = [0, 0, 0]; var res; var white = _Color.default.parse('white'); var c = 100; while (c--) { for (var i = 0; i < id.length; ++i) { rgb[i % 3] = (rgb[i % 3] * 31 + id.charCodeAt(i) * 173) % 255; } res = new _Color.default([rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, 1]); if (res.getContrastWith(white) > 2 && rgb[0] + rgb[1] + rgb[2] > 50) { break; } } return res; } // https://lab.daithangminh.vn/home_co/carddone/markerclusterer.js var loadMarkerClustererSync = null; var lastOpenInfo = null; /*** * * @param {LocationView} viewerElt * @param {Object} data * @constructor */ function LVPolyline(viewerElt, data) { this.viewerElt = viewerElt; this.map = viewerElt.map; this._polylines = []; this.id = data.id || (0, _stringGenerate.randomIdent)(12); this.polylineData = { geodesic: true, strokeColor: data.color || generateColor(this.id).toString('hex6'), strokeOpacity: 1.0, strokeWeight: 2 }; this.polylineData.path = data.path.map(function (crd) { return (0, _utils.implicitLatLng)(crd); }); this.polylineHL = new google.maps.Polyline(Object.assign({}, this.polylineData, { strokeColor: 'white', strokeWeight: 5 })); this.polyline = new google.maps.Polyline(this.polylineData); this.markers = this.polylineData.path.map(function (crd, i) { var mkr = new google.maps.marker.Marker({ position: crd, // sName: data.name || data.id || this.id, map: this.map, icon: { path: google.maps.SymbolPath.CIRCLE, scale: MARKER_RADIUS, fillColor: this.polylineData.strokeColor, fillOpacity: 1, strokeWeight: 2, strokeColor: MARKER_BORDER_COLOR } }); mkr.setMap(this.map); var infoWindow; if (data.path[i] && data.path[i].info) { infoWindow = new google.maps.InfoWindow(data.path[i].info); mkr.addListener('mouseover', function () { if (lastOpenInfo === infoWindow) return; try { if (lastOpenInfo) lastOpenInfo.close(); } catch (e) {} lastOpenInfo = infoWindow; infoWindow.open({ anchor: mkr, map: this.map, shouldFocus: true }); }.bind(this)); } return mkr; }.bind(this)); this.showRoute = viewerElt.showPolylineRoute; } LVPolyline.prototype.remove = function () { this.polyline.setMap(null); this.polylineHL.setMap(null); this.markers.forEach(function (mk) { mk.setMap(null); }); }; Object.defineProperty(LVPolyline.prototype, 'showRoute', { set: function (value) { this._showRoute = !!value; if (value) { this.polylineHL.setMap(this.map); this.polyline.setMap(this.map); } else { this.polylineHL.setMap(null); this.polyline.setMap(null); } }, get: function () { return this._showRoute; } }); Object.defineProperty(LVPolyline.prototype, 'color', { get: function () { return this.polylineData.strokeColor; } }); Object.defineProperty(LVPolyline.prototype, 'sumDistance', { get: function () { var res = 0; var path = this.polylineData.path; for (var i = 1; i < path.length; ++i) { res += (0, _utils.latLngDistance)(path[i - 1], path[i]); } return res; } }); function LVPoints(viewerElt, data) { this.data = data; this.refData = [data]; this.id = data.id || (0, _stringGenerate.randomIdent)(12); this.latLng = (0, _utils.implicitLatLng)(data); if (!this.latLng) { console.error('Invalid data', data); return; } this.map = viewerElt.map; this.marker = new google.maps.marker.Marker({ position: this.latLng, // sName: data.name || data.id || this.id, // map: this.map, icon: { path: google.maps.SymbolPath.CIRCLE, scale: MARKER_RADIUS, fillColor: data.color || generateColor(this.id).toString(), fillOpacity: 1, strokeWeight: 2, strokeColor: MARKER_BORDER_COLOR } }); // this.marker.setMap(this.map); if (!data.info) return; var infoWindow = new google.maps.InfoWindow(data.info); this.marker.addListener('mouseover', function () { if (lastOpenInfo === infoWindow) return; try { if (lastOpenInfo) lastOpenInfo.close(); } catch (e) {} lastOpenInfo = infoWindow; infoWindow.open({ anchor: this.marker, map: this.map, shouldFocus: true }); }.bind(this)); } LVPoints.prototype.remove = function () { if (this.marker) this.marker.setMap(null); }; /*** * @extends AElement * @constructor */ function LocationView() { this.map = new google.maps.Map(this, { zoom: 8, center: new google.maps.LatLng(21.018755, 105.839729), scaleControl: true, mapId: (0, _stringGenerate.randomIdent)() }); this.marker = null; this._value = null; this.$domSignal = (0, _ACore._)('attachhook').addTo(this); this.domSignal = new _DomSignal.default(this.$domSignal); /*** * @type {LatLng} * @name value * @memberOf LocationView# */ /**** * * @type {LVPolyline[]} */ this.$polylines = []; this._showPolylineRoute = true; /**** * * @type {LVPoints[]} */ this.$points = []; } LocationView.tag = 'LocationView'.toLowerCase(); LocationView.render = function () { return (0, _ACore._)({ class: 'as-location-view' }); }; LocationView.prototype.getPolylineById = function (id) { return this.$polylines.find(function (pll) { return pll.id === id; }) || null; }; LocationView.prototype.getPolylines = function () { return this.$polylines.slice(); }; LocationView.property = {}; LocationView.property.zoom = { set: function (value) { if (!(0, _utils.isRealNumber)(value)) { value = 1; } this.map.setZoom(value); }, get: function () { return this.map.getZoom(); } }; LocationView.property.value = { set: function (value) { value = value || null; var latlng = (0, _utils.implicitLatLng)(value); latlng = latlng || new google.maps.LatLng(21.018755, 105.839729); this.map.setCenter(latlng || new google.maps.LatLng(21.018755, 105.839729)); this._value = value; (0, _LocationPicker.getGoogleMarkerLib)().then(() => { if (this.marker) { this.marker.setMap(null); this.marker = null; } if (latlng && value) { this.marker = new google.maps.marker.AdvancedMarkerElement({ map: this.map, position: latlng }); } }); }, get: function () { return this._value; } }; LocationView.property.polylines = { set: function (polylines) { this._polylines = polylines || []; this.$polylines.forEach(function (pll) { pll.remove(); }); (0, _LocationPicker.getGoogleMarkerLib)().then(() => { this.$polylines = polylines.map(function (pll) { return new LVPolyline(this, pll); }.bind(this)); var zoom; var center; var points = this.$polylines.reduce(function (ac, $polyline) { return ac.concat($polyline.polylineData.path); }, []); var bounds = points.reduce(function (ac, cr) { ac.extend(cr); return ac; }, new google.maps.LatLngBounds()); this.domSignal.once('update_view', function () { if (points.length > 1) { zoom = (0, _utils.getMapZoomLevel)(this.getBoundingClientRect(), bounds); center = bounds.getCenter(); } else { zoom = 17; center = points[0] || new google.maps.LatLng(21.018755, 105.839729); } zoom = Math.min(zoom, 17); this.map.setZoom(zoom); this.map.setCenter(center); }.bind(this), 100); this.domSignal.emit('update_view'); }); }, get: function () { return this._polylines; } }; LocationView.property.showPolylineRoute = { set: function (value) { this._showPolylineRoute = !!value; this.$polylines.forEach(function (pll) { pll.showRoute = value; }); }, get: function () { return this._showPolylineRoute; } }; LocationView.property.points = { set: function (points) { this.$points.forEach(function (point) { point.remove(); }); this._points = points || []; (0, _LocationPicker.getGoogleMarkerLib)().then(() => { var rp = this._points.reduce(function (ac, pointData) { var id = pointData.id; var point; if (id && ac.dict[id]) { ac.dict[id].refData.push(pointData); } else { point = new LVPoints(this, pointData); ac.dict[point.id] = point; ac.arr.push(point); } return ac; }.bind(this), { arr: [], dict: {} }); this.$points = rp.arr; var zoom; var center; var latLngs = this.$points.map(function (p) { return p.latLng; }, []).filter(function (x) { return !!x; }); var bounds = latLngs.reduce(function (ac, cr) { ac.extend(cr); return ac; }, new google.maps.LatLngBounds()); var markers = this.$points.map(function (p) { return p.marker; }, []).filter(function (x) { return !!x; }); this.pointsCluster = new _MarkerClusterer.default(this.map, markers, { imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m' }); this.domSignal.once('update_view', function () { if (points.length > 1) { zoom = (0, _utils.getMapZoomLevel)(this.getBoundingClientRect(), bounds); center = bounds.getCenter(); } else { zoom = 17; center = points[0] || new google.maps.LatLng(21.018755, 105.839729); } zoom = Math.min(zoom, 17); this.map.setZoom(zoom); this.map.setCenter(center); }.bind(this), 100); this.domSignal.emit('update_view'); }); }, get: function () { return this._points; } }; _ACore.default.install(LocationView); var _default = LocationView; exports.default = _default;