3namespace Bitrix\Location\Source\Google;
5use Bitrix\Location\Entity\Location;
6use Bitrix\Location\Entity\Generic\Collection;
7use Bitrix\Location\Entity\Location\Parents;
8use Bitrix\Location\Exception\RuntimeException;
9use Bitrix\Location\Repository\Location\Capability\IFindByCoords;
10use Bitrix\Location\Repository\Location\Capability\IFindByExternalId;
11use Bitrix\Location\Repository\Location\Capability\IFindByText;
12use Bitrix\Location\Repository\Location\Capability\IFindParents;
13use Bitrix\Location\Repository\Location\IRepository;
14use Bitrix\Location\Repository\Location\ISource;
15use Bitrix\Location\Service\LocationService;
16use Bitrix\Location\Source\BaseRepository;
17use Bitrix\Location\Source\Google\Converters;
18use Bitrix\Location\Source\Google\Converters\BaseConverter;
19use Bitrix\Location\Source\Google\Requesters;
20use Bitrix\Location\Source\Google\Requesters\BaseRequester;
21use \Bitrix\Location\Common\CachedPool;
22use Bitrix\Main\Localization\Loc;
23use Bitrix\Main\Web\HttpClient;
25Loc::loadMessages(__FILE__);
66 if (
$sourceCode !== self::$sourceCode || $locationExternalId ===
'')
75 'placeid' => $locationExternalId,
76 'language' => $this->googleSource->convertLang($languageId),
83 $foundLocations = $this->
find(
87 'latlng' => implode(
',', [$lat, $lng]),
88 'language' => $this->googleSource->convertLang($languageId),
92 return $foundLocations[0] ??
null;
110 'language' => $this->googleSource->convertLang($languageId)
117 foreach ($collection->getItems() as $item)
119 if (
$location->getExternalId() === $item->getExternalId())
131 Parents $parentResultCollection,
135 if ($collection->
count() <= 0)
140 $candidatesTypes = [];
144 $candidate = $collection[
$i];
146 if (
$location->getExternalId() === $candidate->getExternalId())
151 $candidateType = $candidate->getType();
153 if ($candidateType ===
Location\Type::UNKNOWN)
169 if (in_array($candidateType, $parentTypes,
true))
174 $candidatesTypes[] = [
$i, $candidateType];
177 if (
count($candidatesTypes) <= 0)
182 if (
count($candidatesTypes) > 1)
184 $typeColumn = array_column($candidatesTypes, 1);
185 array_multisort($typeColumn, SORT_ASC, $candidatesTypes);
188 return $collection[$candidatesTypes[0][0]];
197 if (
$location->getSourceCode() !== self::$sourceCode ||
$location->getExternalId() ==
'')
210 $rawData = $this->
find(
215 'language' => $languageId,
220 $ancestorsRawData = $ancestorDataConverter->convert($rawData,
$location->getType());
225 foreach ($ancestorsRawData as
$data)
232 'query' =>
$data[
'NAME'],
234 'location' => $latLon,
235 'language' => $languageId,
251 $result->addItem($localParent);
253 if ($llParents = $localParent->getParents())
255 foreach ($llParents as $localParent)
257 $result->addItem($localParent);
267 $parentSource->getExternalId(),
274 $result->addItem($detailedParent);
290 return LocationService::getInstance()->findByExternalId(
305 return new Finder($requester, $converter);
314 protected function find($requester, $converter =
null,
array $findParams = [])
316 if ($this->apiKey ===
'')
319 Loc::getMessage(
'LOCATION_ADDRESS_REPOSITORY_API_KEY_ERROR'),
324 $finder = $this->
buildFinder($requester, $converter);
325 $findParams[
'key'] = $this->apiKey;
327 return $finder->find($findParams);
333 return self::$sourceCode;
const REPOSITORY_FIND_API_KEY_ERROR
findParents(Location $location, string $languageId)
findByCoords(float $lat, float $lng, int $zoom, string $languageId)
isCollectionContainLocation(Location $location, Collection $collection)
buildFinder($requester, $converter)
findLocalLocationByExternalId(Location $location)
chooseParentFromCollection(Location $location, Collection $collection, Parents $parentResultCollection, array $parentTypes)
find($requester, $converter=null, array $findParams=[])
findByText(string $query, string $languageId)
findByExternalId(string $locationExternalId, string $sourceCode, string $languageId)
__construct(string $apiKey, HttpClient $httpClient, GoogleSource $googleSource, CachedPool $cachePool=null)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
const LOCATION_SEARCH_SCOPE_INTERNAL
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"