2013-01-08 50 views
0

如何在symfony2和VichGeographicalBundle中设置自定义标记?VichGeographicalBundle和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) }} 

一切工作正常,除了标记,我无法找到如何将其设置为自定义图像(图像/自定义.PNG)。

我试图在config.yml中注入一个服务,但我的知识太差。

+0

可能重复[如何在VichGeographicalBundle中使用Symfony2中的群集?](http://stackoverflow.com/questions/14214127/how-can-i-use-集群功能于vichgeographicalbundle换Symfony2的) – Marcelo

回答

0

尝试类似:

<?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 
     } 
    } 
} 

而在你的configs:

services: 
    ... 
    vich_geographical.icon_generator.default: 
     class: YourBundle\Map\Marker\Icon\CustomDefaultIconGenerator 
     public: false 

但它看起来像标记的支持是捆绑有点不完整的。必须有更好的方法来做到这一点;)