stadiamaps / api
Stadia Maps 地理空间 API 提供您构建出色应用程序所需的数据。
v1.3.0
2024-09-04 18:12 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
README
Stadia Maps 地理空间 API 提供您构建出色应用程序所需的数据。
更多信息,请访问 https://docs.stadiamaps.com。
安装与使用
要求
PHP 7.4 及更高版本。
Composer
要使用 Composer 安装绑定,请在 composer.json
中添加类似以下内容:
{ "require": { "stadiamaps/stadiamaps-api-php": "1.*" } }
然后运行 composer install
手动安装
下载文件并包含 autoload.php
<?php require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
入门指南
首先,您需要一个 Stadia Maps API 密钥。然后,您可以使用或引入(根据您的安装方法)此包。以下是一个代码示例。
<?php // Pick one: // // Composer: // use OpenAPI\Client\Configuration; // use OpenAPI\Client\Api\GeocodingApi; // use OpenAPI\Client\ApiException; // use GuzzleHttp; // // Manual installation: // require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization // NOTE: manual installation users will need the full path, like // OpenAPI\Client\Configuration $config = Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); $apiInstance = new GeocodingApi( new GuzzleHttp\Client(), $config ); $text = '1600 Pennsylvania Ave NW'; // The place name (address, venue name, etc.) to search for. try { $result = $apiInstance->autocomplete($text); print_r($result); } catch (Exception $e) { echo 'Exception when calling GeocodingApi->autocomplete: ', $e->getMessage(), PHP_EOL; }
更多示例,请参阅 集成测试。