承接 shumex/geocode 相关项目开发

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

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

shumex/geocode

Composer 安装命令:

composer require shumex/geocode

包简介

Google Geocode API for Laravel

README 文档

README

A simple Laravel service provider for Google Geocoding API.

Installation

This package can be installed via Composer.

Run composer require command.

composer require shumex/geocode

Laravel 5.5

Both the service provider and alias will be automatically installed by Laravel 5.5 package discovery.

Configuration

Add the following line to the .env file:

GEOCODE_GOOGLE_APIKEY=<your_google_api_key>

You can optionally set the response language.

GEOCODE_GOOGLE_LANGUAGE=en # pt-BR, es, de, it, fr, en-GB

Supported Languages for Google Maps Geocoding API.

Usage

You can find data from addresses:

try {
    $response = Geocode::make()->address('Saporischschja', 'de');
    if ($response) {
        echo $response->latitude();
        echo "<br>";
        echo $response->longitude();
        echo "<br>";
        echo $response->formattedAddress();
        echo "<br>";
    }
} catch (GeoException $exception) {
    echo $exception->getMessage();
}

// Output
// 35.139567
// 47.8388
// Saporischschja, Ukraine, 69061

Or from latitude/longitude:

try {
    $response = Geocode::make()->latLng(47.850437, 35.135653, 'en');
    if ($response) {
        echo $response->latitude();
        echo "<br>";
        echo $response->longitude();
        echo "<br>";
        echo $response->formattedAddress();
        echo "<br>";
    }
} catch (GeoException $exception) {
    echo $exception->getMessage();
}

// Output
// 47.850437
// 35.135653
// Volhohrads'ka St, 27, Zaporizhzhia, Zaporiz'ka oblast, Ukraine, 69000

If you need other data rather than formatted address, latitude, longitude, you can use the raw() method:

try {
    $response = Geocode::make()->latLng(40.7637931,-73.9722014);
    if ($response) {
        echo $response->raw()->address_components[8]['types'][0];
        echo $response->raw()->address_components[8]['long_name'];
    }
} catch (GeoException $exception) {
    echo $exception->getMessage();
}

// Output
// postal_code
// 10153

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固