Google maps api 3 VichGeographicalBundle和Symfony2中的自定义标记

Google maps api 3 VichGeographicalBundle和Symfony2中的自定义标记,google-maps-api-3,symfony-2.1,Google Maps Api 3,Symfony 2.1,如何在symfony2和中设置自定义标记 我的地图文件构造函数: public function __construct(EntityManager $em, $iconGenerator) { parent::__construct(); // configure your map in the constructor // by setting the options $this->setShowZoomControl(true); $t

如何在symfony2和中设置自定义标记

我的地图文件构造函数:

 public function __construct(EntityManager $em, $iconGenerator)
{
    parent::__construct();

    // configure your map in the constructor 
    // by setting the options

    $this->setShowZoomControl(true);
    $this->setZoom(15);
    $this->setAutoZoom(false);
    $this->setContainerId('map_canvas');
    $this->setWidth(630);
    $this->setHeight(200);
}
我的细枝呼唤:

{{ vichgeo_map_for('showShop',shop) }}
一切正常,除了标记,我找不到如何将其设置为自定义图像(image/custom.png)

我试图在config.yml中注入服务,但我的知识太贫乏。

尝试以下方法:

<?php

namespace YourBundle\Map\Marker\Icon;

use Vich\GeographicalBundle\Map\Marker\Icon\IconGeneratorInterface;
use ..\Shop; // set the correct path

class CustomDefaultIconGenerator implements IconGeneratorInterface
{
    /**
     * {@inheritDoc}
     */
    public function generateIcon($obj)
    {
        if ($obj instanceof Shop) {
            return '/images/custom.gif'; // make sure the path is correct
        }
    }
}
但在捆绑包中,标记支持似乎有点不完整。一定有更好的办法;)

可能重复的
services:
    ...
    vich_geographical.icon_generator.default:
        class: YourBundle\Map\Marker\Icon\CustomDefaultIconGenerator
        public: false