cethyworks/google-map-display-bundle

提供了一种从地址(使用javascript API)显示谷歌地图的方式,尽可能最简约、不显眼的实现方法。

安装: 290

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:symfony-bundle

v2.1 2017-08-09 03:57 UTC

This package is not auto-updated.

Last update: 2024-09-24 16:36:24 UTC


README

提供了一种从地址(使用javascript API)显示谷歌地图的方式,尽可能最简约、不显眼的实现方法。

CircleCI

安装

1. 使用Composer require

$ composer require cethyworks/google-map-display-bundle 

2. 注册包

// AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new Cethyworks\ContentInjectorBundle\CethyworksContentInjectorBundle(),
            new Cethyworks\GooglePlaceAutocompleteBundle\CethyworksGooglePlaceAutocompleteBundle(),
        ];
        // ...

如何使用

1. 更新(可选)你的config.yml

cethyworks_google_map_display:
    google:
        api_key: 'your_api_key'

2. 调用处理器以添加地图

// retrieve the command handler
/** @var GoogleMapDisplayCommandHandler $handler */
$commandHandler = $container->get(GoogleMapDisplayCommandHandler::class);
// add address & html id to display the map
$commandHandler->addMap('map_id', 'address 1');
// optionnally add other maps 
// $commandHandler->addMap('map2', 'address 2');
// ...

4. 完成!(处理器将自动注册命令)

工作原理

ContentInjectorSubscriber将自动将包含javascript代码(包含mapIds、地址和google api_key)的模板注入到Response中。

附加信息

Cethyworks\ContentInjectorBundle

谷歌地图JS API文档