定制 mapslat/mapslat-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mapslat/mapslat-php

最新稳定版本:v2.0.0

Composer 安装命令:

composer require mapslat/mapslat-php

包简介

Package provides the ability to interact with the Maps.lat API.

README 文档

README

This is a Maps.lat APi client written in PHP. This package contains methods for interacting with APi. Below are some usage examples. You can find more information about the APi in the Maps.lat documentation.

Installation

You must use Composer to install this package. You can install Composer using the command.

curl -sS https://getcomposer.org/installer | php

Package supports PHP version 8.0 and higher. To install this package, run the following command.

composer require mapslat/mapslat-php

Usage

The examples below assume that you are using Composer autoloader in your application. The autoloader is called by the following code.

require 'vendor/autoload.php';
use Mapslat\Mapslat;

Request structure

Create an instance of the class and pass one or two parameters. The first parameter is your API key. The second optional parameter is the $throw flag, which determines whether to throw exceptions on errors (defaults to true).

$mapslat = new Mapslat($apiKey);

The request is built from an array or from a json string that you pass to the method you are calling.

// array as input data
$search = $mapslat->search([
	'query' => 'chicago',
	'limit' => 1
]);

// or json as input data
$search = $mapslat->search('{
	"query": "london",
	"limit": 1
}');

Response structure

The response is returned as an instance of Symfony\Contracts\HttpClient\ResponseInterface. You can call interface methods that return headers, data, http status, etc. See the Symfony HttpClient documentation for more details.

// get response data
$isoline = $mapslat->isoline('{
	"lon": 13.37467722463873,
	"lat": 52.55351817997314,
	"costing": "auto",
	"polygons": true,
	"time": 5
}')->toArray();

// get status code
$statusCode = $mapslat->search([
	'query' => 'chicago',
	'limit' => 1
])->getStatusCode();

// get response headers
$reverse = $mapslat->reverse([
	'lon' => -73.99672895945677,
	'lat' => 40.72494710252593
]);
$headers = $reverse->getHeaders();

// get raw response
$rawResponse = $mapslat->search([
	'query' => 'miami beach',
	'limit' => 3
])->getContent();

Requests to API

For each Maps.lat API endpoint, there is a method for interactions.

Geocoding

// forward geocoding
$data = $mapslat->search($payload)->toArray();

// reverse geocoding
$data = $mapslat->reverse($payload)->toArray();

// geocoding lookup
$data = $mapslat->lookup($payload)->toArray();

Address autocomplete

$data = $mapslat->autocomplete($payload)->toArray();

Routing

// routing
$data = $mapslat->route($payload)->toArray();

// optimal route
$data = $mapslat->optimal($payload)->toArray();

//routing locate
$data = $mapslat->locate($payload)->toArray();

Isoline

$data = $mapslat->isoline($payload)->toArray();

Matrix

$data = $mapslat->matrix($payload)->toArray();

Map matching

// matching routes
$data = $mapslat->match($payload)->toArray();

// matching attributes
$data = $mapslat->attributes($payload)->toArray();

Contribute

This package is Open Source, published under the MIT license. You can participate in its development and improvement.

We will be glad if you take part in the work on this package. Create issues if you find bugs, develop your own and review other people's pull requests, respond to other people's issues, and so on.

Support and feedback

Be sure to visit the Maps.lat documentation for additional information about our API.

If you find a bug, please submit the issue in Github directly.

If you need further assistance email us at support@maps.lat.

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-30