Update
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
<?php
|
||||
|
||||
$urlProviderTechDomain = (new \Bitrix\Main\License\UrlProvider())->getTechDomain();
|
||||
|
||||
if (\Bitrix\Main\Application::getInstance()->getLicense()->isCis())
|
||||
{
|
||||
$locationOsmServiceUrl = 'https://osm-ru-002.' . $urlProviderTechDomain;
|
||||
$locationOsmMapServiceUrl = 'https://osm-ru-001.' . $urlProviderTechDomain;
|
||||
}
|
||||
else
|
||||
{
|
||||
$locationOsmServiceUrl = 'https://osm-de-002.' . $urlProviderTechDomain;
|
||||
$locationOsmMapServiceUrl = 'https://osm-de-001.' . $urlProviderTechDomain;
|
||||
}
|
||||
|
||||
$location_default_option = [
|
||||
'log_level' => 400 // Error
|
||||
'log_level' => 400, // Error
|
||||
'osm_service_url' => $locationOsmServiceUrl,
|
||||
'osm_map_service_url' => $locationOsmMapServiceUrl,
|
||||
];
|
||||
|
||||
unset($urlProviderTechDomain, $locationOsmServiceUrl, $locationOsmMapServiceUrl);
|
||||
|
||||
-827
@@ -1,827 +0,0 @@
|
||||
this.BX = this.BX || {};
|
||||
this.BX.Location = this.BX.Location || {};
|
||||
(function (exports,main_core_events,location_core) {
|
||||
'use strict';
|
||||
|
||||
function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } return value; }
|
||||
|
||||
function _classStaticPrivateMethodGet(receiver, classConstructor, method) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } return method; }
|
||||
|
||||
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
||||
|
||||
/**
|
||||
* Loads google source services
|
||||
*/
|
||||
var Loader =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Loader() {
|
||||
babelHelpers.classCallCheck(this, Loader);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Loader, null, [{
|
||||
key: "load",
|
||||
|
||||
/**
|
||||
* Loads google services
|
||||
* @param {string} apiKey
|
||||
* @param {string} languageId
|
||||
* @returns {Promise}
|
||||
*/
|
||||
value: function load(apiKey, languageId) {
|
||||
return new Promise(function (resolve) {
|
||||
if (_classStaticPrivateFieldSpecGet(Loader, Loader, _isGoogleApiLoaded)) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
BX.load([_classStaticPrivateMethodGet(Loader, Loader, _createSrc).call(Loader, apiKey, languageId)], function () {
|
||||
_classStaticPrivateFieldSpecSet(Loader, Loader, _isGoogleApiLoaded, true);
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
}]);
|
||||
return Loader;
|
||||
}();
|
||||
|
||||
var _createSrc = function _createSrc(apiKey, languageId) {
|
||||
return 'https://maps.googleapis.com/maps/api/js?key=' + apiKey + '&libraries=places&language=' + languageId;
|
||||
};
|
||||
|
||||
var _isGoogleApiLoaded = {
|
||||
writable: true,
|
||||
value: false
|
||||
};
|
||||
|
||||
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
||||
|
||||
var Autocompleter =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
/** {string} */
|
||||
|
||||
/** {google.maps.places.AutocompleteService} */
|
||||
|
||||
/** {Promise}*/
|
||||
|
||||
/** {GoogleSource} */
|
||||
|
||||
/** {string} */
|
||||
|
||||
/** {number} */
|
||||
function Autocompleter(props) {
|
||||
var _this = this;
|
||||
|
||||
babelHelpers.classCallCheck(this, Autocompleter);
|
||||
|
||||
_convertToLocationsList.add(this);
|
||||
|
||||
_initAutocompleteService.add(this);
|
||||
|
||||
_getPredictionPromise.add(this);
|
||||
|
||||
_setPredictionResult.add(this);
|
||||
|
||||
_getPredictionPromiseLocalStorage.add(this);
|
||||
|
||||
_getLocalStoredResults.add(this);
|
||||
|
||||
_languageId.set(this, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_googleAutocompleteService.set(this, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_loaderPromise.set(this, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_source.set(this, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_localStorageKey.set(this, {
|
||||
writable: true,
|
||||
value: 'locationGoogleAutocomplete'
|
||||
});
|
||||
|
||||
_localStorageResCount.set(this, {
|
||||
writable: true,
|
||||
value: 30
|
||||
});
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _languageId, props.languageId);
|
||||
babelHelpers.classPrivateFieldSet(this, _source, props.source); //Because source could still be in the process of loading
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _loaderPromise, props.loaderPromise.then(function () {
|
||||
_classPrivateMethodGet(_this, _initAutocompleteService, _initAutocompleteService2).call(_this);
|
||||
}));
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Autocompleter, [{
|
||||
key: "autocomplete",
|
||||
|
||||
/**
|
||||
* Returns Promise witch will transfer locations list
|
||||
* @param {string} query
|
||||
* @param {object} params
|
||||
* @returns {Promise}
|
||||
*/
|
||||
value: function autocomplete(query, params) {
|
||||
var _this2 = this;
|
||||
|
||||
//Because google.maps.places.AutocompleteService could be still in the process of loading
|
||||
return babelHelpers.classPrivateFieldGet(this, _loaderPromise).then(function () {
|
||||
return _classPrivateMethodGet(_this2, _getPredictionPromise, _getPredictionPromise2).call(_this2, query, params);
|
||||
}, function (error) {
|
||||
return BX.debug(error);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
return Autocompleter;
|
||||
}();
|
||||
|
||||
var _languageId = new WeakMap();
|
||||
|
||||
var _googleAutocompleteService = new WeakMap();
|
||||
|
||||
var _loaderPromise = new WeakMap();
|
||||
|
||||
var _source = new WeakMap();
|
||||
|
||||
var _localStorageKey = new WeakMap();
|
||||
|
||||
var _localStorageResCount = new WeakMap();
|
||||
|
||||
var _getLocalStoredResults = new WeakSet();
|
||||
|
||||
var _getPredictionPromiseLocalStorage = new WeakSet();
|
||||
|
||||
var _setPredictionResult = new WeakSet();
|
||||
|
||||
var _getPredictionPromise = new WeakSet();
|
||||
|
||||
var _initAutocompleteService = new WeakSet();
|
||||
|
||||
var _convertToLocationsList = new WeakSet();
|
||||
|
||||
var _getLocalStoredResults2 = function _getLocalStoredResults2(query, params) {
|
||||
var result = null,
|
||||
storedResults = localStorage.getItem(babelHelpers.classPrivateFieldGet(this, _localStorageKey));
|
||||
|
||||
if (storedResults) {
|
||||
try {
|
||||
storedResults = JSON.parse(storedResults);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Array.isArray(storedResults)) {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = storedResults.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var _step$value = babelHelpers.slicedToArray(_step.value, 2),
|
||||
index = _step$value[0],
|
||||
item = _step$value[1];
|
||||
|
||||
if (item && typeof item.query !== 'undefined' && item.query === query) {
|
||||
result = Object.assign({}, item);
|
||||
storedResults.splice(index, 1);
|
||||
storedResults.push(result);
|
||||
localStorage.setItem(babelHelpers.classPrivateFieldGet(this, _localStorageKey), JSON.stringify(storedResults));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
var _getPredictionPromiseLocalStorage2 = function _getPredictionPromiseLocalStorage2(query, params) {
|
||||
var _this3 = this;
|
||||
|
||||
var result = null,
|
||||
answer = _classPrivateMethodGet(this, _getLocalStoredResults, _getLocalStoredResults2).call(this, query, params);
|
||||
|
||||
if (answer !== null) {
|
||||
result = new Promise(function (resolve) {
|
||||
resolve(_classPrivateMethodGet(_this3, _convertToLocationsList, _convertToLocationsList2).call(_this3, answer.answer, answer.status));
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
var _setPredictionResult2 = function _setPredictionResult2(query, params, answer, status) {
|
||||
var storedResults = localStorage.getItem(babelHelpers.classPrivateFieldGet(this, _localStorageKey));
|
||||
|
||||
if (storedResults) {
|
||||
try {
|
||||
storedResults = JSON.parse(storedResults);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Array.isArray(storedResults)) {
|
||||
storedResults = [];
|
||||
}
|
||||
|
||||
storedResults.push({
|
||||
status: status,
|
||||
query: query,
|
||||
answer: answer
|
||||
});
|
||||
|
||||
if (storedResults.length > babelHelpers.classPrivateFieldGet(this, _localStorageResCount)) {
|
||||
storedResults.shift();
|
||||
}
|
||||
|
||||
localStorage.setItem(babelHelpers.classPrivateFieldGet(this, _localStorageKey), JSON.stringify(storedResults));
|
||||
};
|
||||
|
||||
var _getPredictionPromise2 = function _getPredictionPromise2(query, params) {
|
||||
var _this4 = this;
|
||||
|
||||
var result = _classPrivateMethodGet(this, _getPredictionPromiseLocalStorage, _getPredictionPromiseLocalStorage2).call(this, query, params);
|
||||
|
||||
if (!result) {
|
||||
result = new Promise(function (resolve) {
|
||||
babelHelpers.classPrivateFieldGet(_this4, _googleAutocompleteService).getQueryPredictions({
|
||||
input: query
|
||||
}, function (result, status) {
|
||||
var locationsList = _classPrivateMethodGet(_this4, _convertToLocationsList, _convertToLocationsList2).call(_this4, result, status);
|
||||
|
||||
_classPrivateMethodGet(_this4, _setPredictionResult, _setPredictionResult2).call(_this4, query, params, result, status);
|
||||
|
||||
resolve(locationsList);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
var _initAutocompleteService2 = function _initAutocompleteService2() {
|
||||
if (typeof google === 'undefined' || typeof google.maps.places.AutocompleteService === 'undefined') {
|
||||
throw new Error('google.maps.places.AutocompleteService must be defined');
|
||||
}
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _googleAutocompleteService, new google.maps.places.AutocompleteService());
|
||||
};
|
||||
|
||||
var _convertToLocationsList2 = function _convertToLocationsList2(data, status) {
|
||||
if (status === 'ZERO_RESULTS') {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!data || status !== 'OK') {
|
||||
return false;
|
||||
}
|
||||
|
||||
var result = [];
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = data[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var item = _step2.value;
|
||||
var location = new location_core.Location({
|
||||
sourceCode: babelHelpers.classPrivateFieldGet(this, _source).sourceCode,
|
||||
externalId: item.place_id,
|
||||
name: item.description,
|
||||
languageId: babelHelpers.classPrivateFieldGet(this, _languageId)
|
||||
});
|
||||
result.push(location);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
function _classStaticPrivateFieldSpecGet$1(receiver, classConstructor, descriptor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
||||
|
||||
function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
||||
/**
|
||||
* Class for the autocomplete locations and addresses inputs
|
||||
*/
|
||||
|
||||
var Map =
|
||||
/*#__PURE__*/
|
||||
function (_EventEmitter) {
|
||||
babelHelpers.inherits(Map, _EventEmitter);
|
||||
|
||||
/** {string} */
|
||||
|
||||
/** {google.maps.Map} */
|
||||
|
||||
/** {Promise}*/
|
||||
|
||||
/** {GoogleSource} */
|
||||
|
||||
/** {number} */
|
||||
|
||||
/** {google.maps.Marker} */
|
||||
|
||||
/** {ControlMode}*/
|
||||
function Map(props) {
|
||||
var _this;
|
||||
|
||||
babelHelpers.classCallCheck(this, Map);
|
||||
_this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Map).call(this, props));
|
||||
|
||||
_convertGoogleZoomToInner.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_convertInnerZoomToGoogle.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_initGoogleMap.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_onMapClick.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_fulfillOnChangedEvent.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_createTimer.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_onMarkerUpdatePosition.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_emitOnChangedEvent.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_getPositionToLocationPromise.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_convertLocationToPosition.add(babelHelpers.assertThisInitialized(_this));
|
||||
|
||||
_languageId$1.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_googleMap.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_loaderPromise$1.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_googleSource.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_zoom.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_locationMarker.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_mode.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_geocoder.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_locationRepository.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_defaultPosition.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_changeDelay.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
_timerId.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: ''
|
||||
});
|
||||
|
||||
_isUpdating.set(babelHelpers.assertThisInitialized(_this), {
|
||||
writable: true,
|
||||
value: false
|
||||
});
|
||||
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _languageId$1, props.languageId);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _googleSource, props.googleSource);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _zoom, props.zoom || 10);
|
||||
|
||||
var _location = props.location || null;
|
||||
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository, props.locationRepository || new location_core.LocationRepository());
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _defaultPosition, props.defaultPosition || {
|
||||
latitude: 54.719208,
|
||||
longitude: 20.488515
|
||||
});
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _changeDelay, props.changeDelay || 500);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _mode, props.mode); //Because googleSource could still be in the process of loading
|
||||
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _loaderPromise$1, props.loaderPromise.then(function () {
|
||||
_classPrivateMethodGet$1(babelHelpers.assertThisInitialized(_this), _initGoogleMap, _initGoogleMap2).call(babelHelpers.assertThisInitialized(_this), props.mapContainer, _location, babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(_this), _zoom));
|
||||
}));
|
||||
return _this;
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Map, [{
|
||||
key: "update",
|
||||
value: function update(location) {
|
||||
var position = _classPrivateMethodGet$1(this, _convertLocationToPosition, _convertLocationToPosition2).call(this, location);
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _isUpdating, true);
|
||||
babelHelpers.classPrivateFieldGet(this, _locationMarker).setPosition(position);
|
||||
babelHelpers.classPrivateFieldSet(this, _isUpdating, false);
|
||||
babelHelpers.classPrivateFieldGet(this, _googleMap).panTo(position);
|
||||
}
|
||||
}, {
|
||||
key: "onChangedEventSubscribe",
|
||||
value: function onChangedEventSubscribe(listener) {
|
||||
this.subscribe(_classStaticPrivateFieldSpecGet$1(Map, Map, _onChangedEvent), listener);
|
||||
}
|
||||
}, {
|
||||
key: "mode",
|
||||
set: function set(mode) {
|
||||
babelHelpers.classPrivateFieldSet(this, _mode, mode);
|
||||
babelHelpers.classPrivateFieldGet(this, _locationMarker).setDraggable(mode === location_core.ControlMode.edit);
|
||||
}
|
||||
}, {
|
||||
key: "zoom",
|
||||
set: function set(innerZoom) {
|
||||
if (babelHelpers.classPrivateFieldGet(this, _googleMap)) {
|
||||
babelHelpers.classPrivateFieldGet(this, _googleMap).setZoom(_classPrivateMethodGet$1(this, _convertInnerZoomToGoogle, _convertInnerZoomToGoogle2).call(this, innerZoom));
|
||||
}
|
||||
},
|
||||
get: function get() {
|
||||
if (babelHelpers.classPrivateFieldGet(this, _googleMap)) {
|
||||
return _classPrivateMethodGet$1(this, _convertGoogleZoomToInner, _convertGoogleZoomToInner2).call(this, babelHelpers.classPrivateFieldGet(this, _googleMap).getZoom());
|
||||
}
|
||||
}
|
||||
}]);
|
||||
return Map;
|
||||
}(main_core_events.EventEmitter);
|
||||
|
||||
var _languageId$1 = new WeakMap();
|
||||
|
||||
var _googleMap = new WeakMap();
|
||||
|
||||
var _loaderPromise$1 = new WeakMap();
|
||||
|
||||
var _googleSource = new WeakMap();
|
||||
|
||||
var _zoom = new WeakMap();
|
||||
|
||||
var _locationMarker = new WeakMap();
|
||||
|
||||
var _mode = new WeakMap();
|
||||
|
||||
var _geocoder = new WeakMap();
|
||||
|
||||
var _locationRepository = new WeakMap();
|
||||
|
||||
var _defaultPosition = new WeakMap();
|
||||
|
||||
var _changeDelay = new WeakMap();
|
||||
|
||||
var _timerId = new WeakMap();
|
||||
|
||||
var _isUpdating = new WeakMap();
|
||||
|
||||
var _convertLocationToPosition = new WeakSet();
|
||||
|
||||
var _getPositionToLocationPromise = new WeakSet();
|
||||
|
||||
var _emitOnChangedEvent = new WeakSet();
|
||||
|
||||
var _onMarkerUpdatePosition = new WeakSet();
|
||||
|
||||
var _createTimer = new WeakSet();
|
||||
|
||||
var _fulfillOnChangedEvent = new WeakSet();
|
||||
|
||||
var _onMapClick = new WeakSet();
|
||||
|
||||
var _initGoogleMap = new WeakSet();
|
||||
|
||||
var _convertInnerZoomToGoogle = new WeakSet();
|
||||
|
||||
var _convertGoogleZoomToInner = new WeakSet();
|
||||
|
||||
var _onChangedEvent = {
|
||||
writable: true,
|
||||
value: 'onChanged'
|
||||
};
|
||||
|
||||
var _convertLocationToPosition2 = function _convertLocationToPosition2(location) {
|
||||
var lat, lon;
|
||||
|
||||
if (location) {
|
||||
lat = location.latitude;
|
||||
lon = location.longitude;
|
||||
} else {
|
||||
lat = babelHelpers.classPrivateFieldGet(this, _defaultPosition).latitude;
|
||||
lon = babelHelpers.classPrivateFieldGet(this, _defaultPosition).longitude;
|
||||
}
|
||||
|
||||
return new google.maps.LatLng(lat, lon);
|
||||
};
|
||||
|
||||
var _getPositionToLocationPromise2 = function _getPositionToLocationPromise2(position) {
|
||||
var _this2 = this;
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
babelHelpers.classPrivateFieldGet(_this2, _geocoder).geocode({
|
||||
'location': position
|
||||
}, function (results, status) {
|
||||
if (status === 'OK' && results[0]) {
|
||||
resolve(results[0].place_id);
|
||||
} else if (status === 'ZERO_RESULTS') {
|
||||
resolve('');
|
||||
} else {
|
||||
throw Error('Geocoder failed due to: ' + status);
|
||||
}
|
||||
});
|
||||
}).then(function (placeId) {
|
||||
var result;
|
||||
|
||||
if (placeId) {
|
||||
result = babelHelpers.classPrivateFieldGet(_this2, _locationRepository).findByExternalId(placeId, babelHelpers.classPrivateFieldGet(_this2, _googleSource).sourceCode, babelHelpers.classPrivateFieldGet(_this2, _languageId$1));
|
||||
} else {
|
||||
result = new Promise(function (resolve) {
|
||||
resolve(null);
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
};
|
||||
|
||||
var _emitOnChangedEvent2 = function _emitOnChangedEvent2(location) {
|
||||
if (babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit) {
|
||||
this.emit(_classStaticPrivateFieldSpecGet$1(Map, Map, _onChangedEvent), {
|
||||
location: location
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var _onMarkerUpdatePosition2 = function _onMarkerUpdatePosition2() {
|
||||
if (!babelHelpers.classPrivateFieldGet(this, _isUpdating) && babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit) {
|
||||
_classPrivateMethodGet$1(this, _createTimer, _createTimer2).call(this, babelHelpers.classPrivateFieldGet(this, _locationMarker).getPosition());
|
||||
}
|
||||
};
|
||||
|
||||
var _createTimer2 = function _createTimer2(position) {
|
||||
var _this3 = this;
|
||||
|
||||
if (babelHelpers.classPrivateFieldGet(this, _timerId) !== null) {
|
||||
clearTimeout(babelHelpers.classPrivateFieldGet(this, _timerId));
|
||||
}
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _timerId, setTimeout(function () {
|
||||
babelHelpers.classPrivateFieldSet(_this3, _timerId, null);
|
||||
babelHelpers.classPrivateFieldGet(_this3, _googleMap).panTo(position);
|
||||
|
||||
_classPrivateMethodGet$1(_this3, _fulfillOnChangedEvent, _fulfillOnChangedEvent2).call(_this3, position);
|
||||
}, babelHelpers.classPrivateFieldGet(this, _changeDelay)));
|
||||
};
|
||||
|
||||
var _fulfillOnChangedEvent2 = function _fulfillOnChangedEvent2(position) {
|
||||
_classPrivateMethodGet$1(this, _getPositionToLocationPromise, _getPositionToLocationPromise2).call(this, position).then(_classPrivateMethodGet$1(this, _emitOnChangedEvent, _emitOnChangedEvent2).bind(this));
|
||||
};
|
||||
|
||||
var _onMapClick2 = function _onMapClick2(position) {
|
||||
if (babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit) {
|
||||
babelHelpers.classPrivateFieldGet(this, _locationMarker).setPosition(position);
|
||||
|
||||
_classPrivateMethodGet$1(this, _createTimer, _createTimer2).call(this, position);
|
||||
}
|
||||
};
|
||||
|
||||
var _initGoogleMap2 = function _initGoogleMap2(mapNode, location, zoom) {
|
||||
var _this4 = this;
|
||||
|
||||
if (typeof google === 'undefined' || typeof google.maps.Map === 'undefined') {
|
||||
throw new Error('google.maps.Map must be defined');
|
||||
}
|
||||
|
||||
var position = _classPrivateMethodGet$1(this, _convertLocationToPosition, _convertLocationToPosition2).call(this, location);
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _googleMap, new google.maps.Map(mapNode, {
|
||||
center: position,
|
||||
zoom: zoom
|
||||
}));
|
||||
babelHelpers.classPrivateFieldGet(this, _googleMap).addListener('click', function (e) {
|
||||
_classPrivateMethodGet$1(_this4, _onMapClick, _onMapClick2).call(_this4, e.latLng);
|
||||
});
|
||||
babelHelpers.classPrivateFieldGet(this, _googleMap).addListener('zoom_changed', function (e) {
|
||||
console.log('zoom_changed');
|
||||
console.log(babelHelpers.classPrivateFieldGet(_this4, _googleMap).getZoom());
|
||||
});
|
||||
|
||||
if (typeof google.maps.Marker === 'undefined') {
|
||||
throw new Error('google.maps.Marker must be defined');
|
||||
}
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _locationMarker, new google.maps.Marker({
|
||||
position: position,
|
||||
map: babelHelpers.classPrivateFieldGet(this, _googleMap),
|
||||
animation: google.maps.Animation.DROP,
|
||||
draggable: babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit
|
||||
}));
|
||||
babelHelpers.classPrivateFieldGet(this, _locationMarker).addListener('position_changed', function () {
|
||||
_classPrivateMethodGet$1(_this4, _onMarkerUpdatePosition, _onMarkerUpdatePosition2).call(_this4);
|
||||
});
|
||||
|
||||
if (typeof google.maps.Geocoder === 'undefined') {
|
||||
throw new Error('google.maps.Geocoder must be defined');
|
||||
}
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _geocoder, new google.maps.Geocoder());
|
||||
};
|
||||
|
||||
var _convertInnerZoomToGoogle2 = function _convertInnerZoomToGoogle2(innerZoom) {
|
||||
var result;
|
||||
if (innerZoom <= location_core.ZoomType.World) result = 1;else if (innerZoom <= location_core.ZoomType.Country) result = 4;else if (innerZoom <= location_core.ZoomType.Region) result = 6;else if (innerZoom <= location_core.ZoomType.City) result = 11;else if (innerZoom <= location_core.ZoomType.Street) result = 16;else result = 18;
|
||||
return result;
|
||||
};
|
||||
|
||||
var _convertGoogleZoomToInner2 = function _convertGoogleZoomToInner2(gZoom) {
|
||||
var result;
|
||||
if (gZoom <= 5) result = location_core.ZoomType.World;else if (gZoom <= 7) result = location_core.ZoomType.Country;else if (gZoom <= 9) result = location_core.ZoomType.Region;else if (gZoom <= 10) result = location_core.ZoomType.City;else if (gZoom <= 15) result = location_core.ZoomType.Street;else if (gZoom > 15) result = location_core.ZoomType.Building;
|
||||
return result;
|
||||
};
|
||||
|
||||
function _classPrivateMethodGet$2(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
||||
|
||||
var GoogleSource =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function GoogleSource(props) {
|
||||
babelHelpers.classCallCheck(this, GoogleSource);
|
||||
|
||||
_createAutocompleter.add(this);
|
||||
|
||||
_code.set(this, {
|
||||
writable: true,
|
||||
value: 'GOOGLE'
|
||||
});
|
||||
|
||||
_languageId$2.set(this, {
|
||||
writable: true,
|
||||
value: ''
|
||||
});
|
||||
|
||||
_autocompleter.set(this, {
|
||||
writable: true,
|
||||
value: null
|
||||
});
|
||||
|
||||
_loaderPromise$2.set(this, {
|
||||
writable: true,
|
||||
value: null
|
||||
});
|
||||
|
||||
babelHelpers.classPrivateFieldSet(this, _languageId$2, props.languageId);
|
||||
babelHelpers.classPrivateFieldSet(this, _loaderPromise$2, Loader.load(props.apiKey, props.languageId));
|
||||
}
|
||||
|
||||
babelHelpers.createClass(GoogleSource, [{
|
||||
key: "createMap",
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Element} mapContainer
|
||||
* @param {Location} location
|
||||
* @param mode
|
||||
* @param zoom
|
||||
* @return {MapBase}
|
||||
* todo: initial zoom
|
||||
*/
|
||||
value: function createMap(mapContainer, location, mode, zoom) {
|
||||
return new Map({
|
||||
googleSource: this,
|
||||
languageId: babelHelpers.classPrivateFieldGet(this, _languageId$2),
|
||||
loaderPromise: babelHelpers.classPrivateFieldGet(this, _loaderPromise$2),
|
||||
mapContainer: mapContainer,
|
||||
location: location,
|
||||
mode: mode,
|
||||
zoom: zoom
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "autocompleter",
|
||||
get: function get() {
|
||||
if (babelHelpers.classPrivateFieldGet(this, _autocompleter) === null) {
|
||||
babelHelpers.classPrivateFieldSet(this, _autocompleter, _classPrivateMethodGet$2(this, _createAutocompleter, _createAutocompleter2).call(this, babelHelpers.classPrivateFieldGet(this, _languageId$2)));
|
||||
}
|
||||
|
||||
return babelHelpers.classPrivateFieldGet(this, _autocompleter);
|
||||
}
|
||||
}, {
|
||||
key: "sourceCode",
|
||||
get: function get() {
|
||||
return babelHelpers.classPrivateFieldGet(this, _code);
|
||||
}
|
||||
}]);
|
||||
return GoogleSource;
|
||||
}();
|
||||
|
||||
var _code = new WeakMap();
|
||||
|
||||
var _languageId$2 = new WeakMap();
|
||||
|
||||
var _autocompleter = new WeakMap();
|
||||
|
||||
var _loaderPromise$2 = new WeakMap();
|
||||
|
||||
var _createAutocompleter = new WeakSet();
|
||||
|
||||
var _createAutocompleter2 = function _createAutocompleter2(languageId) {
|
||||
return new Autocompleter({
|
||||
source: this,
|
||||
languageId: languageId,
|
||||
loaderPromise: babelHelpers.classPrivateFieldGet(this, _loaderPromise$2)
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates Source using code and source init params
|
||||
*/
|
||||
|
||||
var SourceFactory =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function SourceFactory() {
|
||||
babelHelpers.classCallCheck(this, SourceFactory);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(SourceFactory, null, [{
|
||||
key: "createSource",
|
||||
value: function createSource(sourceCode, sourceParams) {
|
||||
//todo: make the event for custom and tests sources.
|
||||
if (sourceCode === 'GOOGLE') {
|
||||
var params = Object.assign({}, sourceParams);
|
||||
params.languageId = BX.message('LANGUAGE_ID');
|
||||
return new GoogleSource(params);
|
||||
} else {
|
||||
throw new Error('WrongSourceType', 'Source "' + sourceCode + '" does not exist');
|
||||
}
|
||||
}
|
||||
}]);
|
||||
return SourceFactory;
|
||||
}();
|
||||
|
||||
exports.SourceFactory = SourceFactory;
|
||||
|
||||
}((this.BX.Location.Source = this.BX.Location.Source || {}),BX.Event,BX.Location.Core));
|
||||
//# sourceMappingURL=source.bundle.js.map
|
||||
-1
File diff suppressed because one or more lines are too long
@@ -22,7 +22,6 @@ return [
|
||||
'ui.entity-editor',
|
||||
'ui.common',
|
||||
'ui.viewer',
|
||||
'ui.vue',
|
||||
'location.core',
|
||||
'location.google',
|
||||
'location.osm',
|
||||
|
||||
+103
-130
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable */
|
||||
this.BX = this.BX || {};
|
||||
this.BX.Location = this.BX.Location || {};
|
||||
(function (exports,ui_vue,ui_designTokens,location_google,main_popup,location_source,ui_forms,location_core,location_widget,main_core_events,main_core) {
|
||||
(function (exports,ui_designTokens,location_google,main_popup,location_source,ui_forms,location_core,location_widget,main_core_events,main_core) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -108,55 +108,6 @@ this.BX.Location = this.BX.Location || {};
|
||||
return result;
|
||||
}
|
||||
|
||||
var AddressApplier = ui_vue.Vue.extend({
|
||||
props: {
|
||||
address: {
|
||||
required: true
|
||||
},
|
||||
addressFormat: {
|
||||
required: true
|
||||
},
|
||||
isHidden: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleApplyClick: function handleApplyClick() {
|
||||
this.$emit('apply', {
|
||||
address: this.address
|
||||
});
|
||||
},
|
||||
convertAddressToString: function convertAddressToString(address) {
|
||||
if (!address) {
|
||||
return '';
|
||||
}
|
||||
return address.toString(this.addressFormat, location_core.AddressStringConverter.STRATEGY_TYPE_TEMPLATE_COMMA);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
addressString: function addressString() {
|
||||
if (!this.address) {
|
||||
return '';
|
||||
}
|
||||
return this.address.toString(this.addressFormat, location_core.AddressStringConverter.STRATEGY_TYPE_TEMPLATE_COMMA, location_core.AddressStringConverter.CONTENT_TYPE_TEXT);
|
||||
},
|
||||
containerStyles: function containerStyles() {
|
||||
return {
|
||||
display: this.isHidden ? 'none' : 'flex'
|
||||
};
|
||||
},
|
||||
containerClasses: function containerClasses() {
|
||||
return this.isHidden ? {
|
||||
hidden: true
|
||||
} : {};
|
||||
},
|
||||
localize: function localize() {
|
||||
return ui_vue.Vue.getFilteredPhrases('LOCATION_WIDGET_');
|
||||
}
|
||||
},
|
||||
template: "\n\t\t<div\n\t\t\t:class=\"containerClasses\"\n\t\t\t:style=\"containerStyles\"\n\t\t\tclass=\"location-map-address-changed\"\n\t\t>\n\t\t\t<div class=\"location-map-address-changed-inner\">\n\t\t\t<div class=\"location-map-address-changed-title\">\n\t\t\t\t{{localize.LOCATION_WIDGET_AUI_ADDRESS_CHANGED_NEW_ADDRESS}}\n\t\t\t</div>\n\t\t\t<div class=\"location-map-address-changed-text\">{{addressString}}</div>\n\t\t\t</div>\n\t\t\t<button @click=\"handleApplyClick\" type=\"button\" class=\"location-map-address-apply-btn\">\n\t\t\t\t{{localize.LOCATION_WIDGET_AUI_ADDRESS_APPLY}}\n\t\t\t</button>\n\t\t</div>\t\n\t"
|
||||
});
|
||||
|
||||
function _classPrivateMethodInitSpec$1(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); }
|
||||
function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
||||
function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
||||
@@ -237,7 +188,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
return true;
|
||||
}
|
||||
|
||||
var _templateObject$1, _templateObject2$1, _templateObject3;
|
||||
var _templateObject$1, _templateObject2$1, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
||||
function _classPrivateMethodInitSpec$2(obj, privateSet) { _checkPrivateRedeclaration$2(obj, privateSet); privateSet.add(obj); }
|
||||
function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$2(obj, privateMap); privateMap.set(obj, value); }
|
||||
function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
||||
@@ -249,37 +200,46 @@ this.BX.Location = this.BX.Location || {};
|
||||
var _map = /*#__PURE__*/new WeakMap();
|
||||
var _mode = /*#__PURE__*/new WeakMap();
|
||||
var _address$1 = /*#__PURE__*/new WeakMap();
|
||||
var _prevAddress = /*#__PURE__*/new WeakMap();
|
||||
var _popup = /*#__PURE__*/new WeakMap();
|
||||
var _addressString = /*#__PURE__*/new WeakMap();
|
||||
var _addressApplier = /*#__PURE__*/new WeakMap();
|
||||
var _addressFormat$1 = /*#__PURE__*/new WeakMap();
|
||||
var _gallery = /*#__PURE__*/new WeakMap();
|
||||
var _locationRepository = /*#__PURE__*/new WeakMap();
|
||||
var _isMapRendered = /*#__PURE__*/new WeakMap();
|
||||
var _mapInnerContainer = /*#__PURE__*/new WeakMap();
|
||||
var _geocodingService = /*#__PURE__*/new WeakMap();
|
||||
var _contentWrapper = /*#__PURE__*/new WeakMap();
|
||||
var _applyAddressElement = /*#__PURE__*/new WeakMap();
|
||||
var _applyAddressButtonElement = /*#__PURE__*/new WeakMap();
|
||||
var _addressApplyTextElement = /*#__PURE__*/new WeakMap();
|
||||
var _userLocationPoint = /*#__PURE__*/new WeakMap();
|
||||
var _createAddressApplier = /*#__PURE__*/new WeakSet();
|
||||
var _onLocationChanged = /*#__PURE__*/new WeakSet();
|
||||
var _renderPopup = /*#__PURE__*/new WeakSet();
|
||||
var _createApplyAddressElement = /*#__PURE__*/new WeakSet();
|
||||
var _onApplyAddressClick = /*#__PURE__*/new WeakSet();
|
||||
var _extractLatLon = /*#__PURE__*/new WeakSet();
|
||||
var _convertAddressToLocation = /*#__PURE__*/new WeakSet();
|
||||
var _setLocationInternal = /*#__PURE__*/new WeakSet();
|
||||
var _renderMap = /*#__PURE__*/new WeakSet();
|
||||
var _hideApplyAddress = /*#__PURE__*/new WeakSet();
|
||||
var _showApplyAddress = /*#__PURE__*/new WeakSet();
|
||||
var _getAddressAsText = /*#__PURE__*/new WeakSet();
|
||||
var MapPopup = /*#__PURE__*/function (_EventEmitter) {
|
||||
babelHelpers.inherits(MapPopup, _EventEmitter);
|
||||
function MapPopup(props) {
|
||||
var _this;
|
||||
babelHelpers.classCallCheck(this, MapPopup);
|
||||
_this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MapPopup).call(this, props));
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _getAddressAsText);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _showApplyAddress);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _hideApplyAddress);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _renderMap);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _setLocationInternal);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _convertAddressToLocation);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _extractLatLon);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _onApplyAddressClick);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _createApplyAddressElement);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _renderPopup);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _onLocationChanged);
|
||||
_classPrivateMethodInitSpec$2(babelHelpers.assertThisInitialized(_this), _createAddressApplier);
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _map, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
@@ -292,6 +252,10 @@ this.BX.Location = this.BX.Location || {};
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _prevAddress, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _popup, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
@@ -300,10 +264,6 @@ this.BX.Location = this.BX.Location || {};
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _addressApplier, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _addressFormat$1, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
@@ -312,10 +272,6 @@ this.BX.Location = this.BX.Location || {};
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _locationRepository, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _isMapRendered, {
|
||||
writable: true,
|
||||
value: false
|
||||
@@ -324,11 +280,19 @@ this.BX.Location = this.BX.Location || {};
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _geocodingService, {
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _contentWrapper, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _contentWrapper, {
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _applyAddressElement, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _applyAddressButtonElement, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$1(babelHelpers.assertThisInitialized(_this), _addressApplyTextElement, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
@@ -341,9 +305,6 @@ this.BX.Location = this.BX.Location || {};
|
||||
BX.debug('map must be instance of Map');
|
||||
}
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _map, props.map);
|
||||
if (props.geocodingService instanceof location_core.GeocodingServiceBase) {
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _geocodingService, props.geocodingService);
|
||||
}
|
||||
babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(_this), _map).onLocationChangedEventSubscribe(_classPrivateMethodGet$2(babelHelpers.assertThisInitialized(_this), _onLocationChanged, _onLocationChanged2).bind(babelHelpers.assertThisInitialized(_this)));
|
||||
if (!(props.popup instanceof Popup)) {
|
||||
BX.debug('popup must be instance of Popup');
|
||||
@@ -356,11 +317,9 @@ this.BX.Location = this.BX.Location || {};
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _addressString, new AddressString({
|
||||
addressFormat: babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(_this), _addressFormat$1)
|
||||
}));
|
||||
_classPrivateMethodGet$2(babelHelpers.assertThisInitialized(_this), _createAddressApplier, _createAddressApplier2).call(babelHelpers.assertThisInitialized(_this));
|
||||
if (props.gallery) {
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _gallery, props.gallery);
|
||||
}
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository, props.locationRepository);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _userLocationPoint, props.userLocationPoint);
|
||||
return _this;
|
||||
}
|
||||
@@ -371,6 +330,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
babelHelpers.classPrivateFieldSet(this, _mode, props.mode);
|
||||
babelHelpers.classPrivateFieldSet(this, _isMapRendered, false);
|
||||
babelHelpers.classPrivateFieldSet(this, _mapInnerContainer, main_core.Tag.render(_templateObject$1 || (_templateObject$1 = babelHelpers.taggedTemplateLiteral(["<div class=\"location-map-inner\"></div>"]))));
|
||||
_classPrivateMethodGet$2(this, _createApplyAddressElement, _createApplyAddressElement2).call(this);
|
||||
_classPrivateMethodGet$2(this, _renderPopup, _renderPopup2).call(this, props.bindElement, babelHelpers.classPrivateFieldGet(this, _mapInnerContainer));
|
||||
}
|
||||
}, {
|
||||
@@ -383,7 +343,14 @@ this.BX.Location = this.BX.Location || {};
|
||||
return;
|
||||
}
|
||||
babelHelpers.classPrivateFieldGet(_this2, _popup).show();
|
||||
if (!babelHelpers.classPrivateFieldGet(_this2, _isMapRendered)) {
|
||||
if (babelHelpers.classPrivateFieldGet(_this2, _isMapRendered)) {
|
||||
babelHelpers.classPrivateFieldGet(_this2, _map).location = location;
|
||||
if (babelHelpers.classPrivateFieldGet(_this2, _gallery)) {
|
||||
babelHelpers.classPrivateFieldGet(_this2, _gallery).location = location;
|
||||
}
|
||||
_this2.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onShowedEvent));
|
||||
babelHelpers.classPrivateFieldGet(_this2, _map).onMapShow();
|
||||
} else {
|
||||
_classPrivateMethodGet$2(_this2, _renderMap, _renderMap2).call(_this2, {
|
||||
location: location
|
||||
}).then(function () {
|
||||
@@ -394,13 +361,6 @@ this.BX.Location = this.BX.Location || {};
|
||||
babelHelpers.classPrivateFieldGet(_this2, _map).onMapShow();
|
||||
});
|
||||
babelHelpers.classPrivateFieldSet(_this2, _isMapRendered, true);
|
||||
} else {
|
||||
babelHelpers.classPrivateFieldGet(_this2, _map).location = location;
|
||||
if (babelHelpers.classPrivateFieldGet(_this2, _gallery)) {
|
||||
babelHelpers.classPrivateFieldGet(_this2, _gallery).location = location;
|
||||
}
|
||||
_this2.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onShowedEvent));
|
||||
babelHelpers.classPrivateFieldGet(_this2, _map).onMapShow();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -413,7 +373,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
key: "close",
|
||||
value: function close() {
|
||||
babelHelpers.classPrivateFieldGet(this, _popup).close();
|
||||
babelHelpers.classPrivateFieldGet(this, _addressApplier).$props.isHidden = true;
|
||||
_classPrivateMethodGet$2(this, _hideApplyAddress, _hideApplyAddress2).call(this);
|
||||
this.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onClosedEvent));
|
||||
}
|
||||
}, {
|
||||
@@ -447,7 +407,6 @@ this.BX.Location = this.BX.Location || {};
|
||||
babelHelpers.classPrivateFieldSet(this, _map, null);
|
||||
babelHelpers.classPrivateFieldSet(this, _gallery, null);
|
||||
babelHelpers.classPrivateFieldSet(this, _addressString, null);
|
||||
babelHelpers.classPrivateFieldSet(this, _addressApplier, null);
|
||||
babelHelpers.classPrivateFieldGet(this, _popup).destroy();
|
||||
babelHelpers.classPrivateFieldSet(this, _popup, null);
|
||||
main_core.Dom.remove(babelHelpers.classPrivateFieldGet(this, _contentWrapper));
|
||||
@@ -485,26 +444,6 @@ this.BX.Location = this.BX.Location || {};
|
||||
}]);
|
||||
return MapPopup;
|
||||
}(main_core_events.EventEmitter);
|
||||
function _createAddressApplier2() {
|
||||
var _this4 = this;
|
||||
babelHelpers.classPrivateFieldSet(this, _addressApplier, new AddressApplier({
|
||||
propsData: {
|
||||
address: babelHelpers.classPrivateFieldGet(this, _address$1),
|
||||
addressFormat: babelHelpers.classPrivateFieldGet(this, _addressFormat$1),
|
||||
isHidden: true
|
||||
}
|
||||
}));
|
||||
babelHelpers.classPrivateFieldGet(this, _addressApplier).$mount();
|
||||
babelHelpers.classPrivateFieldGet(this, _addressApplier).$on('apply', function (event) {
|
||||
var prevAddress = event.address;
|
||||
babelHelpers.classPrivateFieldSet(_this4, _address$1, prevAddress);
|
||||
babelHelpers.classPrivateFieldGet(_this4, _addressString).address = prevAddress;
|
||||
babelHelpers.classPrivateFieldGet(_this4, _addressApplier).$props.isHidden = true;
|
||||
_this4.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onChangedEvent), {
|
||||
address: prevAddress
|
||||
});
|
||||
});
|
||||
}
|
||||
function _onLocationChanged2(event) {
|
||||
var data = event.getData();
|
||||
var location = data.location;
|
||||
@@ -525,37 +464,55 @@ this.BX.Location = this.BX.Location || {};
|
||||
this.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onChangedEvent), {
|
||||
address: babelHelpers.classPrivateFieldGet(this, _address$1)
|
||||
});
|
||||
babelHelpers.classPrivateFieldGet(this, _addressApplier).$props.isHidden = true;
|
||||
_classPrivateMethodGet$2(this, _hideApplyAddress, _hideApplyAddress2).call(this);
|
||||
} else {
|
||||
babelHelpers.classPrivateFieldGet(this, _addressString).address = address;
|
||||
babelHelpers.classPrivateFieldGet(this, _addressApplier).$props.address = address;
|
||||
babelHelpers.classPrivateFieldGet(this, _addressApplier).$props.isHidden = false;
|
||||
babelHelpers.classPrivateFieldSet(this, _prevAddress, address);
|
||||
main_core.Dom.adjust(babelHelpers.classPrivateFieldGet(this, _addressApplyTextElement), {
|
||||
text: _classPrivateMethodGet$2(this, _getAddressAsText, _getAddressAsText2).call(this, babelHelpers.classPrivateFieldGet(this, _prevAddress))
|
||||
});
|
||||
_classPrivateMethodGet$2(this, _showApplyAddress, _showApplyAddress2).call(this);
|
||||
}
|
||||
if (babelHelpers.classPrivateFieldGet(this, _gallery)) {
|
||||
babelHelpers.classPrivateFieldGet(this, _gallery).location = location;
|
||||
}
|
||||
}
|
||||
function _renderPopup2(bindElement, mapInnerContainer) {
|
||||
var _this5 = this;
|
||||
var _this4 = this;
|
||||
var gallery = '';
|
||||
if (babelHelpers.classPrivateFieldGet(this, _gallery)) {
|
||||
gallery = babelHelpers.classPrivateFieldGet(this, _gallery).render();
|
||||
}
|
||||
var thirdPartyWarningNode = main_core.Tag.render(_templateObject2$1 || (_templateObject2$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"location-map-address-third-party-warning\">\n\t\t\t\t", "\n\t\t\t</div>\n\t\t"])), main_core.Loc.getMessage('LOCATION_WIDGET_THIRD_PARTY_WARNING'));
|
||||
babelHelpers.classPrivateFieldSet(this, _contentWrapper, main_core.Tag.render(_templateObject3 || (_templateObject3 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"location-map-wrapper\">\n\t\t\t\t<div class=\"location-map-container\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t\t", "\n\t\t\t\t", "\n\t\t\t\t", "\n\t\t\t</div>"])), mapInnerContainer, gallery, babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit ? babelHelpers.classPrivateFieldGet(this, _addressString).render({
|
||||
babelHelpers.classPrivateFieldSet(this, _contentWrapper, main_core.Tag.render(_templateObject3 || (_templateObject3 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"location-map-wrapper\">\n\t\t\t\t<div class=\"location-map-container\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t\t", "\n\t\t\t\t", "\n\t\t\t\t", "\n\t\t\t</div>\n\t\t"])), mapInnerContainer, gallery, babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit ? babelHelpers.classPrivateFieldGet(this, _addressString).render({
|
||||
address: babelHelpers.classPrivateFieldGet(this, _address$1)
|
||||
}) : '', thirdPartyWarningNode, babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit ? babelHelpers.classPrivateFieldGet(this, _addressApplier).$el : ''));
|
||||
}) : '', thirdPartyWarningNode, babelHelpers.classPrivateFieldGet(this, _mode) === location_core.ControlMode.edit ? babelHelpers.classPrivateFieldGet(this, _applyAddressElement) : ''));
|
||||
main_core.Event.bind(babelHelpers.classPrivateFieldGet(this, _contentWrapper), 'click', function (e) {
|
||||
return e.stopPropagation();
|
||||
});
|
||||
main_core.Event.bind(babelHelpers.classPrivateFieldGet(this, _contentWrapper), 'mouseover', function (e) {
|
||||
return _this5.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onMouseOverEvent), e);
|
||||
return _this4.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onMouseOverEvent), e);
|
||||
});
|
||||
main_core.Event.bind(babelHelpers.classPrivateFieldGet(this, _contentWrapper), 'mouseout', function (e) {
|
||||
return _this5.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onMouseOutEvent), e);
|
||||
return _this4.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onMouseOutEvent), e);
|
||||
});
|
||||
this.bindElement = bindElement;
|
||||
babelHelpers.classPrivateFieldGet(this, _popup).setContent(babelHelpers.classPrivateFieldGet(this, _contentWrapper));
|
||||
_classPrivateMethodGet$2(this, _hideApplyAddress, _hideApplyAddress2).call(this);
|
||||
}
|
||||
function _createApplyAddressElement2() {
|
||||
babelHelpers.classPrivateFieldSet(this, _applyAddressButtonElement, main_core.Tag.render(_templateObject4 || (_templateObject4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<button @click=\"handleApplyClick\" type=\"button\" class=\"location-map-address-apply-btn\">\n\t\t\t\t", "\n\t\t\t</button>\n\t\t"])), main_core.Loc.getMessage('LOCATION_WIDGET_AUI_ADDRESS_APPLY')));
|
||||
main_core.Event.bind(babelHelpers.classPrivateFieldGet(this, _applyAddressButtonElement), 'click', _classPrivateMethodGet$2(this, _onApplyAddressClick, _onApplyAddressClick2).bind(this));
|
||||
babelHelpers.classPrivateFieldSet(this, _addressApplyTextElement, main_core.Tag.render(_templateObject5 || (_templateObject5 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"location-map-address-changed-text\">\n\t\t\t\t", "\n\t\t\t</div>\n\t\t"])), _classPrivateMethodGet$2(this, _getAddressAsText, _getAddressAsText2).call(this, babelHelpers.classPrivateFieldGet(this, _address$1))));
|
||||
babelHelpers.classPrivateFieldSet(this, _applyAddressElement, main_core.Tag.render(_templateObject6 || (_templateObject6 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"location-map-address-changed\">\n\t\t\t\t<div class=\"location-map-address-changed-inner\">\n\t\t\t\t<div class=\"location-map-address-changed-title\">\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t\t", "\n\t\t\t</div>\t\n\t\t"])), main_core.Loc.getMessage('LOCATION_WIDGET_AUI_ADDRESS_CHANGED_NEW_ADDRESS'), babelHelpers.classPrivateFieldGet(this, _addressApplyTextElement), babelHelpers.classPrivateFieldGet(this, _applyAddressButtonElement)));
|
||||
}
|
||||
function _onApplyAddressClick2() {
|
||||
babelHelpers.classPrivateFieldSet(this, _address$1, babelHelpers.classPrivateFieldGet(this, _prevAddress));
|
||||
babelHelpers.classPrivateFieldGet(this, _addressString).address = babelHelpers.classPrivateFieldGet(this, _prevAddress);
|
||||
_classPrivateMethodGet$2(this, _hideApplyAddress, _hideApplyAddress2).call(this);
|
||||
this.emit(_classStaticPrivateFieldSpecGet(MapPopup, MapPopup, _onChangedEvent), {
|
||||
address: babelHelpers.classPrivateFieldGet(this, _prevAddress)
|
||||
});
|
||||
}
|
||||
function _extractLatLon2(address) {
|
||||
var result = null;
|
||||
@@ -574,18 +531,18 @@ this.BX.Location = this.BX.Location || {};
|
||||
return result;
|
||||
}
|
||||
function _convertAddressToLocation2(address) {
|
||||
var _this6 = this;
|
||||
var _this5 = this;
|
||||
var useUserLocation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
return new Promise(function (resolve) {
|
||||
if (useUserLocation) {
|
||||
resolve(babelHelpers.classPrivateFieldGet(_this6, _userLocationPoint) && babelHelpers.classPrivateFieldGet(_this6, _mode) !== location_core.ControlMode.view ? new location_core.Location({
|
||||
latitude: babelHelpers.classPrivateFieldGet(_this6, _userLocationPoint).latitude,
|
||||
longitude: babelHelpers.classPrivateFieldGet(_this6, _userLocationPoint).longitude
|
||||
resolve(babelHelpers.classPrivateFieldGet(_this5, _userLocationPoint) && babelHelpers.classPrivateFieldGet(_this5, _mode) !== location_core.ControlMode.view ? new location_core.Location({
|
||||
latitude: babelHelpers.classPrivateFieldGet(_this5, _userLocationPoint).latitude,
|
||||
longitude: babelHelpers.classPrivateFieldGet(_this5, _userLocationPoint).longitude
|
||||
}) : null);
|
||||
return;
|
||||
}
|
||||
if (address) {
|
||||
var latLon = _classPrivateMethodGet$2(_this6, _extractLatLon, _extractLatLon2).call(_this6, address);
|
||||
var latLon = _classPrivateMethodGet$2(_this5, _extractLatLon, _extractLatLon2).call(_this5, address);
|
||||
if (latLon) {
|
||||
resolve(new location_core.Location({
|
||||
latitude: latLon[0],
|
||||
@@ -614,6 +571,22 @@ this.BX.Location = this.BX.Location || {};
|
||||
mode: babelHelpers.classPrivateFieldGet(this, _mode)
|
||||
});
|
||||
}
|
||||
function _hideApplyAddress2() {
|
||||
main_core.Dom.style(babelHelpers.classPrivateFieldGet(this, _applyAddressElement), {
|
||||
display: 'none'
|
||||
});
|
||||
}
|
||||
function _showApplyAddress2() {
|
||||
main_core.Dom.style(babelHelpers.classPrivateFieldGet(this, _applyAddressElement), {
|
||||
display: 'flex'
|
||||
});
|
||||
}
|
||||
function _getAddressAsText2(address) {
|
||||
if (!address) {
|
||||
return '';
|
||||
}
|
||||
return address.toString(babelHelpers.classPrivateFieldGet(this, _addressFormat$1), location_core.AddressStringConverter.STRATEGY_TYPE_TEMPLATE_COMMA, location_core.AddressStringConverter.CONTENT_TYPE_TEXT);
|
||||
}
|
||||
var _onChangedEvent = {
|
||||
writable: true,
|
||||
value: 'onChanged'
|
||||
@@ -695,7 +668,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
var _isAddressChangedByFeature = /*#__PURE__*/new WeakMap();
|
||||
var _isInputNodeValueUpdated = /*#__PURE__*/new WeakMap();
|
||||
var _needWarmBackendAfterAddressChanged = /*#__PURE__*/new WeakMap();
|
||||
var _locationRepository$1 = /*#__PURE__*/new WeakMap();
|
||||
var _locationRepository = /*#__PURE__*/new WeakMap();
|
||||
var _addFeature = /*#__PURE__*/new WeakSet();
|
||||
var _executeFeatureMethod = /*#__PURE__*/new WeakSet();
|
||||
var _emitOnAddressChanged = /*#__PURE__*/new WeakSet();
|
||||
@@ -783,7 +756,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
writable: true,
|
||||
value: true
|
||||
});
|
||||
_classPrivateFieldInitSpec$2(babelHelpers.assertThisInitialized(_this), _locationRepository$1, {
|
||||
_classPrivateFieldInitSpec$2(babelHelpers.assertThisInitialized(_this), _locationRepository, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
@@ -816,9 +789,9 @@ this.BX.Location = this.BX.Location || {};
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _needWarmBackendAfterAddressChanged, props.needWarmBackendAfterAddressChanged);
|
||||
}
|
||||
if (props.locationRepository instanceof location_core.LocationRepository) {
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository$1, props.locationRepository);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository, props.locationRepository);
|
||||
} else if (babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(_this), _needWarmBackendAfterAddressChanged)) {
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository$1, new location_core.LocationRepository());
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository, new location_core.LocationRepository());
|
||||
}
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _state, State.INITIAL);
|
||||
return _this;
|
||||
@@ -1072,7 +1045,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
}
|
||||
function _warmBackendAfterAddressChanged2(address) {
|
||||
if (address.location !== null && address.location.id <= 0) {
|
||||
babelHelpers.classPrivateFieldGet(this, _locationRepository$1).findParents(address.location);
|
||||
babelHelpers.classPrivateFieldGet(this, _locationRepository).findParents(address.location);
|
||||
}
|
||||
}
|
||||
function _onInputFocus2(e) {
|
||||
@@ -1752,7 +1725,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
var _languageId$1 = /*#__PURE__*/new WeakMap();
|
||||
var _addressFormat$4 = /*#__PURE__*/new WeakMap();
|
||||
var _sourceCode = /*#__PURE__*/new WeakMap();
|
||||
var _locationRepository$2 = /*#__PURE__*/new WeakMap();
|
||||
var _locationRepository$1 = /*#__PURE__*/new WeakMap();
|
||||
var _userLocationPoint$1 = /*#__PURE__*/new WeakMap();
|
||||
var _presetLocationsProvider = /*#__PURE__*/new WeakMap();
|
||||
var _prompt = /*#__PURE__*/new WeakMap();
|
||||
@@ -1864,7 +1837,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
_classPrivateFieldInitSpec$7(babelHelpers.assertThisInitialized(_this), _locationRepository$2, {
|
||||
_classPrivateFieldInitSpec$7(babelHelpers.assertThisInitialized(_this), _locationRepository$1, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
@@ -1940,7 +1913,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _sourceCode, props.sourceCode);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _address$3, props.address);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _presetLocationsProvider, props.presetLocationsProvider);
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository$2, props.locationRepository || new location_core.LocationRepository());
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _locationRepository$1, props.locationRepository || new location_core.LocationRepository());
|
||||
babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(_this), _userLocationPoint$1, props.userLocationPoint);
|
||||
_classPrivateMethodGet$6(babelHelpers.assertThisInitialized(_this), _setState, _setState2).call(babelHelpers.assertThisInitialized(_this), State.INITIAL);
|
||||
return _this;
|
||||
@@ -2312,7 +2285,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
function _getLocationDetails2(location) {
|
||||
var _this6 = this;
|
||||
_classPrivateMethodGet$6(this, _setState, _setState2).call(this, State.DATA_LOADING);
|
||||
return babelHelpers.classPrivateFieldGet(this, _locationRepository$2).findByExternalId(location.externalId, location.sourceCode, location.languageId).then(function (detailedLocation) {
|
||||
return babelHelpers.classPrivateFieldGet(this, _locationRepository$1).findByExternalId(location.externalId, location.sourceCode, location.languageId).then(function (detailedLocation) {
|
||||
_classPrivateMethodGet$6(_this6, _setState, _setState2).call(_this6, State.DATA_LOADED);
|
||||
var result;
|
||||
/*
|
||||
@@ -2717,7 +2690,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
return result;
|
||||
}
|
||||
|
||||
var _templateObject$6, _templateObject2$6, _templateObject3$2, _templateObject4;
|
||||
var _templateObject$6, _templateObject2$6, _templateObject3$2, _templateObject4$1;
|
||||
function _classPrivateMethodInitSpec$8(obj, privateSet) { _checkPrivateRedeclaration$b(obj, privateSet); privateSet.add(obj); }
|
||||
function _classPrivateFieldInitSpec$a(obj, privateMap, value) { _checkPrivateRedeclaration$b(obj, privateMap); privateMap.set(obj, value); }
|
||||
function _checkPrivateRedeclaration$b(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
||||
@@ -2889,7 +2862,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
}
|
||||
function _renderViewMode2(container) {
|
||||
babelHelpers.classPrivateFieldSet(this, _input$1, null);
|
||||
babelHelpers.classPrivateFieldSet(this, _viewContainer, main_core.Tag.render(_templateObject4 || (_templateObject4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"ui-title-6\">\n\t\t\t\t", "\n\t\t\t</div>"])), main_core.Text.encode(babelHelpers.classPrivateFieldGet(this, _value$1))));
|
||||
babelHelpers.classPrivateFieldSet(this, _viewContainer, main_core.Tag.render(_templateObject4$1 || (_templateObject4$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"ui-title-6\">\n\t\t\t\t", "\n\t\t\t</div>"])), main_core.Text.encode(babelHelpers.classPrivateFieldGet(this, _value$1))));
|
||||
container.appendChild(babelHelpers.classPrivateFieldGet(this, _viewContainer));
|
||||
}
|
||||
function _refreshLayout2() {
|
||||
@@ -3905,7 +3878,7 @@ this.BX.Location = this.BX.Location || {};
|
||||
babelHelpers.defineProperty(Icon, "TYPE_SEARCH", 'search');
|
||||
babelHelpers.defineProperty(Icon, "TYPE_LOADER", 'loader');
|
||||
|
||||
var _templateObject$9, _templateObject2$7, _templateObject3$3, _templateObject4$1, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
||||
var _templateObject$9, _templateObject2$7, _templateObject3$3, _templateObject4$2, _templateObject5$1, _templateObject6$1, _templateObject7, _templateObject8, _templateObject9;
|
||||
function _classPrivateMethodInitSpec$d(obj, privateSet) { _checkPrivateRedeclaration$j(obj, privateSet); privateSet.add(obj); }
|
||||
function _checkPrivateRedeclaration$j(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
||||
function _classStaticPrivateMethodGet$1(receiver, classConstructor, method) { _classCheckPrivateStaticAccess$7(receiver, classConstructor); return method; }
|
||||
@@ -4091,11 +4064,11 @@ this.BX.Location = this.BX.Location || {};
|
||||
type: _classStaticPrivateMethodGet$1(UIAddress, UIAddress, _chooseInputIconTypeByAddress).call(UIAddress, _classPrivateMethodGet$d(this, _getAddress, _getAddress2).call(this))
|
||||
});
|
||||
this._inputContainer = main_core.Tag.render(_templateObject3$3 || (_templateObject3$3 = babelHelpers.taggedTemplateLiteral(["<div class=\"ui-ctl ui-ctl-w100 ui-ctl-after-icon\">", "", "", "</div>"])), inputIconNode, this._input, this._hiddenInput);
|
||||
this._titleWrapper.appendChild(main_core.Tag.render(_templateObject4$1 || (_templateObject4$1 = babelHelpers.taggedTemplateLiteral(["", ""])), this._fieldsSwitch.render(this._mode)));
|
||||
this._innerWrapper = main_core.Tag.render(_templateObject5 || (_templateObject5 = babelHelpers.taggedTemplateLiteral(["\t\t\t\t\t\t \n\t\t\t\t<div class=\"location-search-control-block\">\t\t\t\t\t\n\t\t\t\t\t", "\n\t\t\t\t</div>"])), this._inputContainer);
|
||||
this._titleWrapper.appendChild(main_core.Tag.render(_templateObject4$2 || (_templateObject4$2 = babelHelpers.taggedTemplateLiteral(["", ""])), this._fieldsSwitch.render(this._mode)));
|
||||
this._innerWrapper = main_core.Tag.render(_templateObject5$1 || (_templateObject5$1 = babelHelpers.taggedTemplateLiteral(["\t\t\t\t\t\t \n\t\t\t\t<div class=\"location-search-control-block\">\t\t\t\t\t\n\t\t\t\t\t", "\n\t\t\t\t</div>"])), this._inputContainer);
|
||||
addressWidgetParams.inputNode = this._input;
|
||||
addressWidgetParams.mapBindElement = inputIconNode;
|
||||
this._addressFieldsContainer = main_core.Tag.render(_templateObject6 || (_templateObject6 = babelHelpers.taggedTemplateLiteral(["<div class=\"location-fields-control-block\"></div>"])));
|
||||
this._addressFieldsContainer = main_core.Tag.render(_templateObject6$1 || (_templateObject6$1 = babelHelpers.taggedTemplateLiteral(["<div class=\"location-fields-control-block\"></div>"])));
|
||||
if (this._fieldsSwitch.state === Switch.STATE_ON) {
|
||||
this._addressFieldsContainer.classList.add('visible');
|
||||
}
|
||||
@@ -4277,5 +4250,5 @@ this.BX.Location = this.BX.Location || {};
|
||||
exports.State = State;
|
||||
exports.UIAddress = UIAddress;
|
||||
|
||||
}((this.BX.Location.Widget = this.BX.Location.Widget || {}),BX,BX,BX.Location.Google,BX.Main,BX.Location.Source,BX,BX.Location.Core,BX.Location.Widget,BX.Event,BX));
|
||||
}((this.BX.Location.Widget = this.BX.Location.Widget || {}),BX,BX.Location.Google,BX.Main,BX.Location.Source,BX,BX.Location.Core,BX.Location.Widget,BX.Event,BX));
|
||||
//# sourceMappingURL=widget.bundle.js.map
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
-67
@@ -1,67 +0,0 @@
|
||||
import {Vue} from 'ui.vue';
|
||||
import {Address, AddressStringConverter} from 'location.core';
|
||||
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
address: {required: true},
|
||||
addressFormat: {required: true},
|
||||
isHidden: {required: true},
|
||||
},
|
||||
methods: {
|
||||
handleApplyClick()
|
||||
{
|
||||
this.$emit('apply', {address: this.address});
|
||||
},
|
||||
convertAddressToString(address: ?Address): string
|
||||
{
|
||||
if (!address)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return address.toString(this.addressFormat, AddressStringConverter.STRATEGY_TYPE_TEMPLATE_COMMA);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
addressString()
|
||||
{
|
||||
if (!this.address)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return this.address.toString(this.addressFormat, AddressStringConverter.STRATEGY_TYPE_TEMPLATE_COMMA, AddressStringConverter.CONTENT_TYPE_TEXT);
|
||||
},
|
||||
containerStyles()
|
||||
{
|
||||
return {
|
||||
display: this.isHidden ? 'none' : 'flex'
|
||||
};
|
||||
},
|
||||
containerClasses()
|
||||
{
|
||||
return this.isHidden ? {hidden: true} : {};
|
||||
},
|
||||
localize()
|
||||
{
|
||||
return Vue.getFilteredPhrases('LOCATION_WIDGET_');
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<div
|
||||
:class="containerClasses"
|
||||
:style="containerStyles"
|
||||
class="location-map-address-changed"
|
||||
>
|
||||
<div class="location-map-address-changed-inner">
|
||||
<div class="location-map-address-changed-title">
|
||||
{{localize.LOCATION_WIDGET_AUI_ADDRESS_CHANGED_NEW_ADDRESS}}
|
||||
</div>
|
||||
<div class="location-map-address-changed-text">{{addressString}}</div>
|
||||
</div>
|
||||
<button @click="handleApplyClick" type="button" class="location-map-address-apply-btn">
|
||||
{{localize.LOCATION_WIDGET_AUI_ADDRESS_APPLY}}
|
||||
</button>
|
||||
</div>
|
||||
`
|
||||
});
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
Type,
|
||||
Dom,
|
||||
Event,
|
||||
Loc
|
||||
Loc,
|
||||
} from 'main.core';
|
||||
import {
|
||||
Address,
|
||||
@@ -11,13 +11,11 @@ import {
|
||||
Location,
|
||||
ControlMode,
|
||||
MapBase,
|
||||
GeocodingServiceBase,
|
||||
AddressStringConverter,
|
||||
LocationType
|
||||
LocationType,
|
||||
} from 'location.core';
|
||||
import {EventEmitter} from 'main.core.events';
|
||||
import { EventEmitter } from 'main.core.events';
|
||||
import AddressString from './addressstring';
|
||||
import AddressApplier from './addressapplier';
|
||||
import Popup from './popup';
|
||||
|
||||
import 'ui.design-tokens';
|
||||
@@ -34,16 +32,17 @@ export default class MapPopup extends EventEmitter
|
||||
#map;
|
||||
#mode;
|
||||
#address;
|
||||
#prevAddress;
|
||||
#popup;
|
||||
#addressString;
|
||||
#addressApplier;
|
||||
#addressFormat;
|
||||
#gallery;
|
||||
#locationRepository;
|
||||
#isMapRendered = false;
|
||||
#mapInnerContainer;
|
||||
#geocodingService;
|
||||
#contentWrapper;
|
||||
#applyAddressElement;
|
||||
#applyAddressButtonElement;
|
||||
#addressApplyTextElement;
|
||||
#userLocationPoint;
|
||||
|
||||
constructor(props)
|
||||
@@ -58,11 +57,6 @@ export default class MapPopup extends EventEmitter
|
||||
|
||||
this.#map = props.map;
|
||||
|
||||
if (props.geocodingService instanceof GeocodingServiceBase)
|
||||
{
|
||||
this.#geocodingService = props.geocodingService;
|
||||
}
|
||||
|
||||
this.#map.onLocationChangedEventSubscribe(this.#onLocationChanged.bind(this));
|
||||
|
||||
if (!(props.popup instanceof Popup))
|
||||
@@ -80,45 +74,17 @@ export default class MapPopup extends EventEmitter
|
||||
this.#addressFormat = props.addressFormat;
|
||||
|
||||
this.#addressString = new AddressString({
|
||||
addressFormat: this.#addressFormat
|
||||
addressFormat: this.#addressFormat,
|
||||
});
|
||||
this.#createAddressApplier();
|
||||
|
||||
if (props.gallery)
|
||||
{
|
||||
this.#gallery = props.gallery;
|
||||
}
|
||||
|
||||
this.#locationRepository = props.locationRepository;
|
||||
this.#userLocationPoint = props.userLocationPoint;
|
||||
}
|
||||
|
||||
#createAddressApplier()
|
||||
{
|
||||
this.#addressApplier = new AddressApplier(
|
||||
{
|
||||
propsData: {
|
||||
address: this.#address,
|
||||
addressFormat: this.#addressFormat,
|
||||
isHidden: true,
|
||||
}
|
||||
}
|
||||
);
|
||||
this.#addressApplier.$mount();
|
||||
this.#addressApplier.$on('apply', (event) => {
|
||||
const prevAddress = event.address;
|
||||
|
||||
this.#address = prevAddress;
|
||||
this.#addressString.address = prevAddress;
|
||||
this.#addressApplier.$props.isHidden = true;
|
||||
|
||||
this.emit(
|
||||
MapPopup.#onChangedEvent,
|
||||
{address: prevAddress}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#onLocationChanged(event: Event)
|
||||
{
|
||||
const data = event.getData();
|
||||
@@ -131,7 +97,7 @@ export default class MapPopup extends EventEmitter
|
||||
this.#addressString.address = address;
|
||||
this.emit(
|
||||
MapPopup.#onChangedEvent,
|
||||
{address: address}
|
||||
{ address },
|
||||
);
|
||||
}
|
||||
else if (address.fieldCollection.isEqual(this.#address.fieldCollection, LocationType.ADDRESS_LINE_1))
|
||||
@@ -147,16 +113,16 @@ export default class MapPopup extends EventEmitter
|
||||
|
||||
this.emit(
|
||||
MapPopup.#onChangedEvent,
|
||||
{address: this.#address}
|
||||
{ address: this.#address },
|
||||
);
|
||||
|
||||
this.#addressApplier.$props.isHidden = true;
|
||||
this.#hideApplyAddress();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.#addressString.address = address;
|
||||
this.#addressApplier.$props.address = address;
|
||||
this.#addressApplier.$props.isHidden = false;
|
||||
this.#prevAddress = address;
|
||||
Dom.adjust(this.#addressApplyTextElement, { text: this.#getAddressAsText(this.#prevAddress) });
|
||||
this.#showApplyAddress();
|
||||
}
|
||||
|
||||
if (this.#gallery)
|
||||
@@ -171,6 +137,7 @@ export default class MapPopup extends EventEmitter
|
||||
this.#mode = props.mode;
|
||||
this.#isMapRendered = false;
|
||||
this.#mapInnerContainer = Tag.render`<div class="location-map-inner"></div>`;
|
||||
this.#createApplyAddressElement();
|
||||
this.#renderPopup(props.bindElement, this.#mapInnerContainer);
|
||||
}
|
||||
|
||||
@@ -195,16 +162,58 @@ export default class MapPopup extends EventEmitter
|
||||
${mapInnerContainer}
|
||||
${gallery}
|
||||
</div>
|
||||
${this.#mode === ControlMode.edit ? this.#addressString.render({address: this.#address}) : ''}
|
||||
${this.#mode === ControlMode.edit ? this.#addressString.render({ address: this.#address }) : ''}
|
||||
${thirdPartyWarningNode}
|
||||
${this.#mode === ControlMode.edit ? this.#addressApplier.$el : ''}
|
||||
</div>`;
|
||||
${this.#mode === ControlMode.edit ? this.#applyAddressElement : ''}
|
||||
</div>
|
||||
`;
|
||||
|
||||
Event.bind(this.#contentWrapper, 'click', (e) => e.stopPropagation());
|
||||
Event.bind(this.#contentWrapper, 'mouseover', (e) => this.emit(MapPopup.#onMouseOverEvent, e));
|
||||
Event.bind(this.#contentWrapper, 'mouseout', (e) => this.emit(MapPopup.#onMouseOutEvent, e));
|
||||
this.bindElement = bindElement;
|
||||
this.#popup.setContent(this.#contentWrapper);
|
||||
this.#hideApplyAddress();
|
||||
}
|
||||
|
||||
#createApplyAddressElement(): void
|
||||
{
|
||||
this.#applyAddressButtonElement = Tag.render`
|
||||
<button @click="handleApplyClick" type="button" class="location-map-address-apply-btn">
|
||||
${Loc.getMessage('LOCATION_WIDGET_AUI_ADDRESS_APPLY')}
|
||||
</button>
|
||||
`;
|
||||
Event.bind(this.#applyAddressButtonElement, 'click', this.#onApplyAddressClick.bind(this));
|
||||
|
||||
this.#addressApplyTextElement = Tag.render`
|
||||
<div class="location-map-address-changed-text">
|
||||
${this.#getAddressAsText(this.#address)}
|
||||
</div>
|
||||
`;
|
||||
|
||||
this.#applyAddressElement = Tag.render`
|
||||
<div class="location-map-address-changed">
|
||||
<div class="location-map-address-changed-inner">
|
||||
<div class="location-map-address-changed-title">
|
||||
${Loc.getMessage('LOCATION_WIDGET_AUI_ADDRESS_CHANGED_NEW_ADDRESS')}
|
||||
</div>
|
||||
${this.#addressApplyTextElement}
|
||||
</div>
|
||||
${this.#applyAddressButtonElement}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
#onApplyAddressClick()
|
||||
{
|
||||
this.#address = this.#prevAddress;
|
||||
this.#addressString.address = this.#prevAddress;
|
||||
this.#hideApplyAddress();
|
||||
|
||||
this.emit(
|
||||
MapPopup.#onChangedEvent,
|
||||
{ address: this.#prevAddress },
|
||||
);
|
||||
}
|
||||
|
||||
get bindElement()
|
||||
@@ -272,10 +281,11 @@ export default class MapPopup extends EventEmitter
|
||||
this.#userLocationPoint && this.#mode !== ControlMode.view
|
||||
? new Location({
|
||||
latitude: this.#userLocationPoint.latitude,
|
||||
longitude: this.#userLocationPoint.longitude
|
||||
longitude: this.#userLocationPoint.longitude,
|
||||
})
|
||||
: null
|
||||
: null,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -288,8 +298,9 @@ export default class MapPopup extends EventEmitter
|
||||
resolve(new Location({
|
||||
latitude: latLon[0],
|
||||
longitude: latLon[1],
|
||||
type: address.getType()
|
||||
type: address.getType(),
|
||||
}));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -317,15 +328,39 @@ export default class MapPopup extends EventEmitter
|
||||
this.#map.mode = mode;
|
||||
}
|
||||
|
||||
#renderMap({location})
|
||||
#renderMap({ location })
|
||||
{
|
||||
return this.#map.render({
|
||||
mapContainer: this.#mapInnerContainer,
|
||||
location: location,
|
||||
mode: this.#mode
|
||||
location,
|
||||
mode: this.#mode,
|
||||
});
|
||||
}
|
||||
|
||||
#hideApplyAddress(): void
|
||||
{
|
||||
Dom.style(this.#applyAddressElement, { display: 'none' });
|
||||
}
|
||||
|
||||
#showApplyAddress(): void
|
||||
{
|
||||
Dom.style(this.#applyAddressElement, { display: 'flex' });
|
||||
}
|
||||
|
||||
#getAddressAsText(address: Address): string
|
||||
{
|
||||
if (!address)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return address.toString(
|
||||
this.#addressFormat,
|
||||
AddressStringConverter.STRATEGY_TYPE_TEMPLATE_COMMA,
|
||||
AddressStringConverter.CONTENT_TYPE_TEXT,
|
||||
);
|
||||
}
|
||||
|
||||
show(useUserLocation: boolean = false): void
|
||||
{
|
||||
this.#convertAddressToLocation(this.#address, useUserLocation)
|
||||
@@ -337,21 +372,7 @@ export default class MapPopup extends EventEmitter
|
||||
|
||||
this.#popup.show();
|
||||
|
||||
if (!this.#isMapRendered)
|
||||
{
|
||||
this.#renderMap({location})
|
||||
.then(() => {
|
||||
if (this.#gallery)
|
||||
{
|
||||
this.#gallery.location = location;
|
||||
}
|
||||
this.emit(MapPopup.#onShowedEvent);
|
||||
this.#map.onMapShow();
|
||||
});
|
||||
|
||||
this.#isMapRendered = true;
|
||||
}
|
||||
else
|
||||
if (this.#isMapRendered)
|
||||
{
|
||||
this.#map.location = location;
|
||||
|
||||
@@ -363,6 +384,20 @@ export default class MapPopup extends EventEmitter
|
||||
this.emit(MapPopup.#onShowedEvent);
|
||||
this.#map.onMapShow();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.#renderMap({ location })
|
||||
.then(() => {
|
||||
if (this.#gallery)
|
||||
{
|
||||
this.#gallery.location = location;
|
||||
}
|
||||
this.emit(MapPopup.#onShowedEvent);
|
||||
this.#map.onMapShow();
|
||||
});
|
||||
|
||||
this.#isMapRendered = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -374,7 +409,7 @@ export default class MapPopup extends EventEmitter
|
||||
close(): void
|
||||
{
|
||||
this.#popup.close();
|
||||
this.#addressApplier.$props.isHidden = true;
|
||||
this.#hideApplyAddress();
|
||||
this.emit(MapPopup.#onClosedEvent);
|
||||
}
|
||||
|
||||
@@ -408,7 +443,6 @@ export default class MapPopup extends EventEmitter
|
||||
this.#map = null;
|
||||
this.#gallery = null;
|
||||
this.#addressString = null;
|
||||
this.#addressApplier = null;
|
||||
|
||||
this.#popup.destroy();
|
||||
this.#popup = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '25.200.0',
|
||||
'VERSION_DATE' => '2025-07-01 11:00:00'
|
||||
'VERSION' => '25.300.0',
|
||||
'VERSION_DATE' => '2025-08-18 10:00:00'
|
||||
];
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Bitrix\Location\Common;
|
||||
|
||||
use Bitrix\Main\Loader;
|
||||
|
||||
/**
|
||||
* Class RegionFinder
|
||||
* @package Bitrix\Location\Common
|
||||
*/
|
||||
class RegionFinder
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Bitrix\Main\LoaderException
|
||||
*/
|
||||
public static function getCurrentRegion(): string
|
||||
{
|
||||
$result = null;
|
||||
|
||||
if (Loader::includeModule('bitrix24'))
|
||||
{
|
||||
$licensePrefix = \CBitrix24::getLicensePrefix();
|
||||
if ($licensePrefix !== false)
|
||||
{
|
||||
$result = (string)$licensePrefix;
|
||||
}
|
||||
}
|
||||
elseif (Loader::includeModule('intranet'))
|
||||
{
|
||||
$result = (string)\CIntranetUtils::getPortalZone();
|
||||
}
|
||||
elseif (defined('LANGUAGE_ID'))
|
||||
{
|
||||
$result = LANGUAGE_ID;
|
||||
}
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
$result = 'en';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?
|
||||
namespace Bitrix\Location\Entity\Address\Normalizer;
|
||||
|
||||
class NullNormalizer implements INormalizer
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function normalize($string)
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Bitrix\Location\Entity\Location;
|
||||
|
||||
use Bitrix\Location\Entity\Location;
|
||||
|
||||
/**
|
||||
* Calculate distance between two Locations
|
||||
* Class DistanceCalculator
|
||||
* @package Bitrix\Location\Entity\Location
|
||||
*/
|
||||
class DistanceCalculator
|
||||
{
|
||||
private const EARTH_RADIUS = 6371;
|
||||
|
||||
/**
|
||||
* @param Location $location1
|
||||
* @param Location $location2
|
||||
* @return bool|float
|
||||
*/
|
||||
public function calculate(Location $location1, Location $location2)
|
||||
{
|
||||
if(
|
||||
empty($location1->getLatitude())
|
||||
|| empty($location1->getLongitude())
|
||||
|| empty($location2->getLatitude())
|
||||
|| empty($location2->getLongitude())
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$lat1 = $location1->getLatitude() / 180 * M_PI;
|
||||
$lat2 = $location2->getLatitude() / 180 * M_PI;
|
||||
$lon1 = $location1->getLongitude() / 180 * M_PI;
|
||||
$lon2 = $location2->getLongitude() / 180 * M_PI;
|
||||
|
||||
return (float)acos(sin($lat1)*sin($lat2)
|
||||
+ cos($lat1)*cos($lat2)
|
||||
* cos($lon2-$lon1))
|
||||
* self::EARTH_RADIUS;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Bitrix\Location\Entity\Location\Factory;
|
||||
|
||||
use Bitrix\Location\Entity\Address\Converter\OrmConverter;
|
||||
use Bitrix\Location\Entity\Location;
|
||||
use Bitrix\Location\Model\EO_Hierarchy_Collection;
|
||||
use Bitrix\Location\Model\EO_Location;
|
||||
use Bitrix\Location\Model\EO_Location_Collection;
|
||||
|
||||
final class OrmFactory
|
||||
{
|
||||
public static function createLocation(EO_Location $ormLocation, string $languageId): Location
|
||||
{
|
||||
$result = (new Location())
|
||||
->setId($ormLocation->getId())
|
||||
->setCode($ormLocation->getCode())
|
||||
->setExternalId($ormLocation->getExternalId())
|
||||
->setSourceCode($ormLocation->getSourceCode())
|
||||
->setType(($ormLocation->getType()))
|
||||
->setLatitude($ormLocation->getLatitude())
|
||||
->setLongitude($ormLocation->getLongitude());
|
||||
|
||||
if($fields = $ormLocation->getFields())
|
||||
{
|
||||
/** @var Location\Field $field */
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$result->setFieldValue($field->getType(), $field->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
foreach($ormLocation->getName() as $ormName)
|
||||
{
|
||||
if($ormName->getLanguageId() === $languageId || $ormName->getLanguageId() == '')
|
||||
{
|
||||
$result->setName($ormName->getName());
|
||||
$result->setLanguageId($ormName->getLanguageId());
|
||||
|
||||
if($ormName->getLanguageId() === $languageId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function createCollection(EO_Location_Collection $collection, string $language)
|
||||
{
|
||||
$result = new Location\Collection();
|
||||
|
||||
foreach ($collection as $item)
|
||||
{
|
||||
$result->addItem(
|
||||
self::createLocation($item, $language)
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function createParentCollection(EO_Hierarchy_Collection $ormHierarchy, string $languageId)
|
||||
{
|
||||
$result = new Location\Parents();
|
||||
|
||||
foreach ($ormHierarchy as $item)
|
||||
{
|
||||
$result->addItem(
|
||||
self::createLocation(
|
||||
$item->getAncestor(),
|
||||
$languageId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Bitrix\Location\Entity\Location;
|
||||
|
||||
use Bitrix\Location\Entity\Location\Collection;
|
||||
|
||||
/**
|
||||
* Interface ILocationRelated
|
||||
* @package Bitrix\Location
|
||||
*/
|
||||
interface IHasLocation
|
||||
{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLocationEntityType(): string;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getLocationCollection(): Collection;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Bitrix\Location\Source\Google\Requesters;
|
||||
|
||||
/**
|
||||
* Interface RequesterBase
|
||||
* @package Bitrix\Location\Source\Google\Requesters
|
||||
*/
|
||||
final class AutocompleteRequester extends BaseRequester
|
||||
{
|
||||
protected $url = 'https://maps.googleapis.com/maps/api/place/autocomplete/json';
|
||||
protected $requiredFields = ['input', 'language', 'key'];
|
||||
protected $fieldsToEncode = ['input'];
|
||||
|
||||
}
|
||||
@@ -6,10 +6,9 @@ use Bitrix\Location\Entity\Source;
|
||||
use Bitrix\Location\Repository\Location\IRepository;
|
||||
use Bitrix\Location\Source\Osm\Api\Api;
|
||||
use Bitrix\Location\StaticMap\ISourceStaticMapService;
|
||||
use Bitrix\Main\Application;
|
||||
use Bitrix\Main\ModuleManager;
|
||||
use Bitrix\Main\Context;
|
||||
use Bitrix\Main\License\UrlProvider;
|
||||
use Bitrix\Main\Config\Option;
|
||||
|
||||
/**
|
||||
* Class OsmSource
|
||||
@@ -20,12 +19,10 @@ final class OsmSource extends Source
|
||||
{
|
||||
public const API_PATH = '/api';
|
||||
|
||||
private UrlProvider $urlProvider;
|
||||
private TokenRequester $tokenRequester;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->urlProvider = new UrlProvider();
|
||||
$this->tokenRequester = (new TokenRequester())->setSource($this);
|
||||
}
|
||||
|
||||
@@ -67,7 +64,7 @@ final class OsmSource extends Source
|
||||
return [
|
||||
'serviceUrl' => $this->getOsmApiUrl(),
|
||||
'mapServiceUrl' => $this->getOsmMapServiceUrl(),
|
||||
'token' => $token ? $token->getToken() : null,
|
||||
'token' => $token?->getToken(),
|
||||
'useGeocodingService' => true,
|
||||
'hostName' => $this->getOsmHostName()
|
||||
];
|
||||
@@ -125,22 +122,12 @@ final class OsmSource extends Source
|
||||
|
||||
public function getOsmServiceUrl(): ?string
|
||||
{
|
||||
if (defined('LOCATION_OSM_SERVICE_URL') && LOCATION_OSM_SERVICE_URL)
|
||||
{
|
||||
return (string)LOCATION_OSM_SERVICE_URL;
|
||||
}
|
||||
|
||||
return 'https://osm-' . $this->getSubDomainSuffix() . '-002.' . $this->urlProvider->getTechDomain();
|
||||
return Option::get('location', 'osm_service_url');
|
||||
}
|
||||
|
||||
public function getOsmMapServiceUrl(): ?string
|
||||
{
|
||||
if (defined('LOCATION_OSM_MAP_SERVICE_URL') && LOCATION_OSM_MAP_SERVICE_URL)
|
||||
{
|
||||
return (string)LOCATION_OSM_MAP_SERVICE_URL;
|
||||
}
|
||||
|
||||
return 'https://osm-' . $this->getSubDomainSuffix() . '-001.' . $this->urlProvider->getTechDomain();
|
||||
return Option::get('location', 'osm_map_service_url');
|
||||
}
|
||||
|
||||
public function getOsmToken(): ?Token
|
||||
@@ -158,11 +145,4 @@ final class OsmSource extends Source
|
||||
|
||||
return !$this->tokenRequester->hasLicenseIssues();
|
||||
}
|
||||
|
||||
private function getSubDomainSuffix(): string
|
||||
{
|
||||
$region = Application::getInstance()->getLicense()->getRegion();
|
||||
|
||||
return in_array($region, ['ru', 'by', 'kz', 'uz'], true) ? 'ru' : 'de';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user