承接 sgoranov/google-maps-tools 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sgoranov/google-maps-tools

Composer 安装命令:

composer require sgoranov/google-maps-tools

包简介

PHP wrapper for Google Maps API

README 文档

README

Build Status

PHP wrapper for Google Maps API

Author

Simeon Goranov - sgoranov@gmail.com

Installation

Update your composer.json adding following

$ composer require sgoranov/google-maps-tools

Usage

Use the Google Maps Geocoding API call to search by address:

$geocode = new Geocode('Car Osvoboditel 13, Sofia, Bulgaria');
$geocode->execute();
$point = $geocode->getFirstPoint();

The point is defined as latitude and longitude:

$latitude = $point->getLatitude();
$longitude = $point->getLongitude();

Use Google Maps Distancematrix API call to calculate the distance between two points:

$dmatrix = new Distancematrix($startPoint, $endPoint);
try {
    $result = $dmatrix->fetch();
} catch (ApiException $e) {
    throw new \InvalidArgumentException('Unable to calculate the distance');
}

Use DistanceCalc library to calculate the distance between multiple points:

$calc = new DistanceCalc();

$geocode = new Geocode('Car Osvoboditel 13, Sofia, Bulgaria');
$geocode->execute();
$point = $geocode->getFirstPoint();
$calc->addPoint($point);

$geocode = new Geocode('Ianko Sakazov 1, Sofia, Bulgaria');
$geocode->execute();
$point = $geocode->getFirstPoint();
$calc->addPoint($point);

$geocode = new Geocode('Georgi Rakovski 96, Sofia, Bulgaria');
$geocode->execute();
$point = $geocode->getFirstPoint();
$calc->addPoint($point);

$distance = $calc->calculate();

Unit testing

To run the test locally execute the following:

vendor/phpunit/phpunit/phpunit

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD
  • 更新时间: 2015-09-10