当我尝试在我的twig文件中显示我的地图时,会出现此错误 我不明白为什么:
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 %}
谢谢!
答案 0 :(得分:2)
使用symfony包,您需要使用ivory_google_map
函数
{% block body %}
{% include "TestFrontBundle:Includes:indexBody.html.twig" %}
{{ ivory_google_map(map) }}
{{ ivory_google_api([map]) }}
{% endblock %}
答案 1 :(得分:0)
你有没有尝试过:
{% block body %}
{% include "TestFrontBundle:Includes:indexBody.html.twig" %}
{{ google_map_container(map) }}
{{ google_map_css(map) }}
{{ google_map_js(map) }}
{% endblock %}