SF2 IvoryGoogleMapBundle-如何在我的.titch中显示地图


SF2 IvoryGoogleMapBundle - How to display the map in my .twig?

当我试图在我的trick文件中显示我的Map时,会出现此错误,并且我不明白为什么:

TestFrontBundle中未知的"google_map"函数:默认值:第11行的index.html.twig。

我的控制器

<?php
namespace Test'ZeroBundle'Controller;
use Symfony'Bundle'FrameworkBundle'Controller'Controller;
use Ivory'GoogleMap'Map;
use Ivory'GoogleMap'Overlays'Animation;
use Ivory'GoogleMap'Overlays'Marker;
class DefaultController extends Controller
{
    public function indexAction()
    {
        $map = new Map();
        $map->setCenter(-34.919,-57.954, true);
        $map->setMapOption('zoom', 13);
        $map->setLanguage('fr');
        $marker = new Marker();
        // Configure your marker options
        $marker->setPrefixJavascriptVariable('marker_');
        $marker->setPosition(-34.919,-57.954, true);
        $marker->setAnimation(Animation::BOUNCE);
        $marker->setOption('clickable', false);
        $marker->setOption('flat', true);
        $marker->setOptions(array(
            'clickable' => false,
            'flat'      => true,
        ));
        $map->addMarker($marker);


        return $this->render('TestZeroBundle:Default:index.html.twig', array(
            'map' => $map
        ));
    }
}

我的小树枝文件

{% extends "::base.html.twig" %}
{%  block title %} ProjectZero {%  endblock %}

{%  block body %}
    {% include "TestFrontBundle:Includes:indexBody.html.twig" %}

        {{ google_map(map) }}

    {%  endblock %}

谢谢!

对于symfony捆绑包,您需要使用ivory_google_map函数

{%  block body %}
    {% include "TestFrontBundle:Includes:indexBody.html.twig" %}
    {{ ivory_google_map(map) }}
    {{ ivory_google_api([map]) }}
{%  endblock %}

你尝试过吗:

{%  block body %}
  {% include "TestFrontBundle:Includes:indexBody.html.twig" %}
  {{ google_map_container(map) }}
  {{ google_map_css(map) }}
  {{ google_map_js(map) }}
{%  endblock %}