happyr/location-bundle

一个用于处理实体地理位置的Symfony2 Bundle

安装次数: 5,150

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 3

分支: 0

公开问题: 0

类型:symfony-bundle

0.5.3 2020-11-11 10:57 UTC

This package is auto-updated.

Last update: 2024-09-11 19:21:33 UTC


README

一个用于处理位置的Symfony2 Bundle。它提供了一个带有不同部分的Location对象,以便清楚地识别位置。

安装

1. 使用composer安装

php composer.phar require happyr/location-bundle

2. 启用Bundle

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Happyr\LocationBundle\HappyrLocationBundle(),
    );
}

3. 添加地理编码器

您需要在配置中指定一个地理编码器服务。地理编码器必须实现GeocoderInterface接口

happyr_location:
    geocoder_service: 'acme.geocoder'

使用方法

//any form 
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('location', 'location', array(
                    'components'=>array(
                        'country'=>true,
                        'city'=>true,
                    )
                ));
    }