承接 martijnoud/distancematrix 相关项目开发

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

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

martijnoud/distancematrix

最新稳定版本:v1.2.0

Composer 安装命令:

composer require martijnoud/distancematrix

包简介

API wrapper to get the distance between two addresses using Google's Distance Matrix API

README 文档

README

Very simple API Wrapper for Google's DistanceMatrix API. Enter two addresses and the class returns the distance between them in meter. Alternatively use Google Static Map API to generate a map with a line plotted between two adresses.

Install

Install using composer:

$ composer require martijnoud/distancematrix

Basic usage

Calculate the distance in meters between the Inktweb.nl office and Paleis Noordeinde in the Hague.

use MartijnOud\DistanceMatrix\DistanceMatrix;

$distanceMatrix = new DistanceMatrix(YOUR_API_KEY_HERE);

$distance = $distanceMatrix->distance([
    'origins' => 'Prof. van der Waalsstraat 2 Alkmaar', 
    'destinations' => 'Paleis Noordeinde Den Haag'
]);

if ($distance > 0) {
	echo round($distance / 1000, 2) . "km"; // 84.5km
}

More control

use MartijnOud\DistanceMatrix\DistanceMatrix;

$distanceMatrix = new DistanceMatrix(YOUR_API_KEY_HERE);

$distance = $distanceMatrix->distance([
	'origins' => 'Leith', 
	'destinations' => 'Arques',
	'mode' => 'walking',
	'language' => 'en-GB',
]);

if ($distance > 0) {
	echo "I would walk " . $distance * 0.00062137119 . " miles"; // I would walk 493.88322020532 miles
}

Generating a map

An API key is not required for this. If you do supply a key make sure this key has premission to use the Static Map API.

use MartijnOud\DistanceMatrix\DistanceMatrix;

$distanceMatrix = new DistanceMatrix();

$image = $distanceMatrix->map([
	'origins' => 'Prof. van der Waalsstraat 2 Alkmaar', // required
	'destinations' => 'Amsterdam', // required
	'size' => '728x200'
]);

if ($image) {
	echo '<img src="'.$image.'" />';
}

google-static-map

Todo

Ideas for future versions.

  • Better error handling, checking rate limit, etc
  • Show a map with a line plotted between two points

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固