geocoder-php/algolia-places-provider

Geocoder AlgoliaPlaces 适配器

0.4.0 2022-07-30 12:09 UTC

This package is auto-updated.

Last update: 2024-09-04 11:04:04 UTC


README

Build Status Latest Stable Version Total Downloads Monthly Downloads Code Coverage Quality Score Software License

这是 PHP Geocoder 的 Algolia Places 提供者。这是一个只读仓库。有关信息和文档,请参阅主仓库

安装

composer require geocoder-php/algolia-places-provider

使用方法

Algolia Places API 每天最多允许每个 IP 地址进行 1000 次免费请求(无需身份验证)。

通过 注册账户,您可以每月进行 100,000 次请求(大约每天 3,000 次)。

见:https://community.algolia.com/places/pricing.html

区域设置

您应该在查询中设置区域设置。如果缺失,非英语国家的结果可能不完整。

use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;

$httpClient = new \Http\Discovery\Psr18Client();

// Unauthenticated
$provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient);
// Authenticated
$provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient, '<your-key>', '<your-app-id>');

$geocoder = new \Geocoder\StatefulGeocoder($provider, 'en');

$result = $geocoder->geocodeQuery(GeocodeQuery::create('Paris')->withLocale('fr-FR'));

贡献

欢迎贡献!向 主仓库 发送拉取请求或报告您在 问题追踪器 中发现的问题。