wr/geocoding-bundle

Contao开源CMS的地理编码组件

0.0.3 2017-07-30 18:13 UTC

This package is auto-updated.

Last update: 2024-09-25 06:38:53 UTC


README

使用此组件,您可以使用Contao 4.4.*通过Google Geocode API轻松计算给定地址、城市、地点或国家的地理位置。

需要Google API密钥。您可以在以下链接下生成API密钥:[https://developers.google.com/maps/documentation/geocoding/get-api-key](https://developers.google.com/maps/documentation/geocoding/get-api-key)

注意

此组件目前处于开发中。请自行承担风险使用!稳定版本将很快推出。当然,您可以在[仓库问题部分](https://github.com/webrealisierung-ch/geocoding-bundle/issues)提交问题和功能请求。谢谢!

如何安装

Contao标准版

在您的项目文件夹中运行以下Composer命令以将地理编码组件添加到项目中:

    ./composer require wr/geocoding-bundle

在所有Contao组件之后将组件添加到`app/AppKernel.php`的`bundles`数组中

public function registerBundles()
    {
        $bundles = [
            .....    
            new Wr\GeocodingBundle\WrGeocodingBundle() //Add this line.
        ];

        ....
        
        return $bundles;
    }

使用以下两个命令清除缓存并预热缓存:

    ./bin/console cache:clear --no-warmup --env=prod
    ./bin/console cache:warmup  --env=prod

转到安装工具并更新数据库。然后登录到后台。

Contao管理版

无需使用Contao Manager

在您的项目文件夹中运行以下Composer命令以将地理编码组件添加到项目中:

    composer require wr/geocoding-bundle

使用以下两个命令清除缓存并预热缓存:

    vendor/bin/contao-console cache:clear --no-warmup
    vendor/bin/contao-console cache:warmup

转到安装工具并更新数据库。然后登录到后台。

使用Contao Manager

  1. 在Contao Manager的搜索栏中搜索组件`wr/geocoding-bundle`,然后单击安装按钮。
  2. 转到安装工具并更新数据库。然后登录到后台。

依赖

  • php: ^7.0
  • symfony/symfony: ^3.3
  • contao/core-bundle: ^4.4

使用方法

您可以使用以下方式使用容器中的类:

$container=\Contao\System::getContainer();
$Geocoder=container->get('wr.geocoding.geocoder');
$Geocoder->calculate($address,$country,$apiKey);

如果请求成功,geocoder对象将返回来自Google API的响应对象,否则它将返回NULL。

或者,您可以访问以下属性。

$Geocoder->lat; //return the latitute
$Geocoder->lng; //return the longitute
$Geocoder->coords; // return the coordinate in seprated with a coma
$Geocoder->formattedAddress; // return the address formatted by the Google Geocoding API
$Geocoder->placeId; //return the Google Place ID
$Geocoder->types; //return the Google Geo Position type
$Geocoder->status; //return the Google API status
$Geocoder->geocoderResponse; //return the response object form the Google API

许可证

地理编码组件根据LGPLv3发布。

文档

遗憾的是,目前没有可用的文档。但是,我们将尽快解决此问题。

联系方式/支持

如需更多信息,请随时与我们联系:[mail@webrealisierung.ch](mailto:mail@webrealisierung.ch)

捐赠

如果您喜欢我们的工作,请随时捐赠。

有几种方式可以向项目捐赠。以下列表包含一些可能性:

  • 通过pull requests贡献您的代码。
  • 测试,测试,测试,并给出反馈。
  • 提交功能或问题。
  • 告诉我们一个笑话。
  • Donate 您知道在编码时每杯咖啡都很重要:)-)