2013-01-08 49 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 

但它看起來像標記的支持是捆綁有點不完整的。必須有更好的方法來做到這一點;)