403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/google/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/google/src/photoservice.js
import {PhotoServiceBase, BasePhotoServiceRequestPhotosPropsType} from "location.core";

export default class PhotoService extends PhotoServiceBase
{
	#map;
	#service;
	#googleSource;
	#loadingPromise;

	constructor(props)
	{
		super(props);
		this.#googleSource = props.googleSource;
		this.#map = props.map;
	}

	#getLoaderPromise()
	{
		if(!this.#loadingPromise)
		{
			//map haven't rendered yet	`
			if(this.#map.loaderPromise === null)
			{
				return;
			}

			this.#loadingPromise = this.#map.loaderPromise.then(() => {
				this.#service = new google.maps.places.PlacesService(this.#map.googleMap);
			});
		}

		return this.#loadingPromise;
	}

	requestPhotos(props: BasePhotoServiceRequestPhotosPropsType): Promise
	{
		return new Promise((resolve) => {

			let promise = this.#getLoaderPromise();

			if(!promise)
			{
				resolve([]);
			}

			let loaderPromise = this.#getLoaderPromise();

			if(!loaderPromise)
			{
				resolve([]);
			}

			loaderPromise
			 .then(() => {
				if(props.location.sourceCode !== this.#googleSource.sourceCode)
				{
					resolve([]);
					return;
				}

				if(props.location.externalId.length <= 0)
				{
					resolve([]);
					return;
				}

				this.#service.getDetails(
					{
						placeId: props.location.externalId,
						fields: ['photos']
					},
					function(place, status)
					{
						let resultPhotos = [];

						if (status === google.maps.places.PlacesServiceStatus.OK)
						{
							if(Array.isArray(place.photos))
							{
								let count = 0;

								for(let gPhoto of place.photos)
								{
									resultPhotos.push({
										url: gPhoto.getUrl(),
										width: gPhoto.width,
										height: gPhoto.height,
										description: Array.isArray(gPhoto.html_attributions) ? gPhoto.html_attributions.join('<br>') : '',
										thumbnail: {
											url: gPhoto.getUrl({
												maxHeight: props.thumbnailHeight,
												maxWidth: props.thumbnailWidth
											}),
											width: props.thumbnailWidth,
											height: props.thumbnailHeight
										}
									});

									count++;

									if(props.maxPhotoCount && count >= props.maxPhotoCount)
									{
										break;
									}
								}
							}
						}
						resolve(resultPhotos);
					}
				);
			});
		});
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit