egeloen / ivory-google-map

Google Map API v3 integration for PHP 5.6+.
MIT License
325 stars 185 forks source link

ReferenceError: google is not defined #255

Closed ALacroix68 closed 7 years ago

ALacroix68 commented 7 years ago

Hello @egeloen,

I'm using Ivory Google maps with Symfony. But I have an error when rendering the map : ReferenceError: google is not defined

My code PHP : `

    $map = new Map();

    $map->setStylesheetOptions([
        'width'     => '100%',
        'height'    => '500px'
    ]);

`

Twig : {{ map(gmap) }} {{ map_js(gmap) }}

With this code in TwigExtension :


    public function getFunctions() {
        return array(
            'map'   => new \Twig_SimpleFunction('map', [$this, 'renderGoogleMap']),
            'map_js'   => new \Twig_SimpleFunction('map_js', [$this, 'renderGoogleMapJs']),
        );
    }

public function renderGoogleMap(Map $map){
        return $this->getMapHelper()->renderHtml($map);
    }

public function renderGoogleMapJs(Map $map){
        return $this->getMapHelper()->renderJavascript($map);
    }

    /**
     * @return MapHelper
     */
    protected function getMapHelper(){
        if($this->mapHelper === NULL){
            $mapHelperBuilder = MapHelperBuilder::create();
            $this->mapHelper = $mapHelperBuilder->build();
        }

        return $this->mapHelper;
    }

What's wrong in my code ?

Thanks in advance, AL