public function build(Map $map, Assets $assets = null)
    {
        $prefix = 'var map, layers = {}, controls = {}, icons = {};' . "\n";

        if (!$assets) {
            return $prefix . $this->javascriptBuilder->encode($map, $this->jsonEncodeFlags);
        }

        $collector = new Collector($assets, $this->javascripts, $this->stylesheets);
        $this->eventDispatcher->addSubscriber($collector);

        $assets->setMap($prefix . $this->javascriptBuilder->encode($map, $this->jsonEncodeFlags));

        $this->eventDispatcher->removeSubscriber($collector);

        return $assets->getMap();
    }
public function build(Map $map, Assets $assets = null)
    {
        $prefix = 'var map, layers = {}, controls = {}, icons = {};' . "\n";

        if (!$assets) {
            return $prefix . $this->javascriptBuilder->encode($map, $this->jsonEncodeFlags);
        }

        $collector = new Collector($assets, $this->javascripts, $this->stylesheets);
        $this->eventDispatcher->addSubscriber($collector);

        $assets->setMap($prefix . $this->javascriptBuilder->encode($map, $this->jsonEncodeFlags));

        $this->eventDispatcher->removeSubscriber($collector);

        return $assets->getMap();
    }
public function build ( Map $ map , Assets $ assets = null ) { $ prefix = 'var map, layers = {}, controls = {}, icons = {};' . "\n" ; if ( ! $ assets ) { return $ prefix . $ this -> javascriptBuilder -> encode ( $ map , $ this -> jsonEncodeFlags ) ; } $ collector = new Collector ( $ assets , $ this -> javascripts , $ this -> stylesheets ) ; $ this -> eventDispatcher -> addSubscriber ( $ collector ) ; $ assets -> setMap ( $ prefix . $ this -> javascriptBuilder -> encode ( $ map , $ this -> jsonEncodeFlags ) ) ; $ this -> eventDispatcher -> removeSubscriber ( $ collector ) ; return $ assets -> getMap ( ) ; }
Build map as a javascript resource.

It always return the generated map no matter if an assets object is given or not. If you want to get the
combined generated assets, just use $assets->getHtml().

@param Map    $map    The map being created.
@param Assets $assets Optional pass an assets instance which collects all required assets.

@return string
Build map as a javascript resource .