| Current Path : /var/www/element/data/element_backup.2025.12.07/revenuestory.ru/bitrix/js/location/osm/src/ |
| Current File : /var/www/element/data/element_backup.2025.12.07/revenuestory.ru/bitrix/js/location/osm/src/osm.js |
import {Type} from 'main.core';
import {BaseSource, SourceCreationError} from 'location.core';
import AutocompleteService from './autocompleteservice';
import MapService from './mapservice';
import GeocodingService from './geocodingservice';
export type OSMConstructorProps = {
languageId: string,
sourceLanguageId: string,
mapService: MapService,
autocompleteService: AutocompleteService,
geocodingService: GeocodingService
}
/**
* Class for the using OpenStreetMap data as data source
*/
export default class OSM extends BaseSource
{
static code = 'OSM';
static #onPropsChangedEvent = 'onPropsChanged';
#languageId = '';
// todo: do we need this here?
#sourceLanguageId = '';
#mapService;
#geocodingService;
#autocompleteService;
constructor(props: OSMConstructorProps)
{
super(props);
if(!Type.isString(props.languageId) || props.languageId.trim() === '')
{
throw new SourceCreationError('props.languageId must be a string');
}
this.#languageId = props.languageId;
if(!Type.isString(props.sourceLanguageId) || props.sourceLanguageId.trim() === '')
{
throw new SourceCreationError('props.sourceLanguageId must be a string');
}
this.#sourceLanguageId = props.sourceLanguageId;
if(!(props.mapService instanceof MapService))
{
throw new SourceCreationError('props.mapService must be instanceof MapService');
}
this.#mapService = props.mapService;
if(!(props.autocompleteService instanceof AutocompleteService))
{
throw new SourceCreationError('props.autocompleteService must be instanceof AutocompleteService');
}
this.#autocompleteService = props.autocompleteService;
if(!(props.geocodingService instanceof GeocodingService))
{
throw new SourceCreationError('props.geocodingService must be instanceof GeocodingService');
}
this.#geocodingService = props.geocodingService;
}
get sourceCode(): string
{
return OSM.code;
}
// todo: move
get map()
{
return this.mapService;
}
get mapService()
{
return this.#mapService;
}
get autocompleteService()
{
return this.#autocompleteService;
}
get geocodingService()
{
return this.#geocodingService;
}
get languageId()
{
return this.#languageId;
}
}