puwnz/google-maps-lib 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

puwnz/google-maps-lib

Composer 安装命令:

composer require puwnz/google-maps-lib

包简介

Library to communicate with Google API

关键字:

README 文档

README

Overview

The Google Lib project provides a Google Map integration for you PHP 7.3+ project. At this time, just geocode is enable in this lib, because my needs is only on this part, but you can open issues to push your needs.

Installation

To install this lib you can just use composer :

composer require puwnz/google-maps-lib

Integration

<?php

use Puwnz\GoogleMapsLib\Constants\SupportedLanguage;
use Puwnz\GoogleMapsLib\Constants\SupportedRegion;
use Puwnz\GoogleMapsLib\Geocode\QueryBuilder\GeocodeQueryBuilder;
use Puwnz\GoogleMapsLib\Geocode\Type\GeocodeComponentQueryType;
use Puwnz\GoogleMapsLib\GoogleServiceFactory;
use Symfony\Component\Validator\Validation;

$geocode = GoogleServiceFactory::create('google-api-key', 'path/log/file', 'http-version');

$components = [
    GeocodeComponentQueryType::COUNTRY => 'FR'
];

$geocodeQueryBuilder = new GeocodeQueryBuilder(Validation::createValidator());

$geocodeQueryBuilder->setAddress('10 rue de la Paix, Paris')
    ->setComponents($components)
    ->setLanguage(SupportedLanguage::FRENCH)
    ->setRegion(SupportedRegion::FR)
    ->setBounds([
        'northeast' => [
            'lat' => 0.0,
            'lng' => 1.0
        ],
        'southwest' => [
            'lat' => -0.0,
            'lng' => -1.0
        ]
    ]);

$response = $geocode->apply($geocodeQueryBuilder);

The first parameter of factory is required, but the path file for a log and http-version are not.

http-version should be a float.

Language supported

Google does not accept all language for their apis. You can found all language supported here

If you don't set the language, google can return partial geocoding response for example.

Testing

The bundle is fully unit tested by PHPUnit with a code coverage close to 100%.

Exception

Some exceptions are trigger in this lib, the next list explain in few words why :

  • \Puwnz\GoogleMapsLib\Geocode\Exception\GeocodeViolationsException is trigger when you set a wrong data on some builder. For example, if you not set lat key on bounds in \Puwnz\GoogleMapsLib\Geocode\QueryBuilder\AddressQueryBuilder

Contribute

We love contributors! This is an open source project. If you'd like to contribute, feel free to propose a PR!

License

The Google Map Lib is under the MIT license. For the full copyright and license information, please read the LICENSE file that was distributed with this source code.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固