biscolab/geocoder

此包已被弃用且不再维护。作者建议使用biscolab/google-maps-php-sdk包。

v1.0 2017-11-18 14:20 UTC

This package is auto-updated.

Last update: 2022-02-01 13:11:03 UTC


README

Google Maps PHP SDK替代

Geocoder

简单的Google Maps Geocoder PHP库。只需几个步骤即可获取选定地址的纬度和经度!

安装

您可以通过composer安装此包

composer require biscolab/geocoder:^1.0

如何使用

  1. 选择地址
$address = 'street <YOUR_STREET>, <YOUR_CITY>, <YOUR_COUNTRY>';
  1. 获取位置
$loc = (new Geocoder($address))->getLocation();
  1. 使用getLocation方法返回的GeocoderLocation对象。要获取纬度(Lat)和经度(Lng),请使用以下方法
/**
 * Return the latitude
 *
 * @return float
 */
$lat = $loc->getLat();

/**
 * Return the longitude
 *
 * @return float
 */
$lng = $loc->getLng();

就是这样!