public function encodeMap(Map $map, Encoder $encoder)
    {
        $output = $encoder->getOutput();
        $hash   = spl_object_hash($map);

        if (!isset($this->initialized[$hash])) {
            $output->prepend(
                sprintf(
                    '%s = L.map(%s);',
                    $encoder->encodeReference($map),
                    $encoder->encodeArguments(array($map->getElementId(), $map->getOptions()))
                )
            );

            $this->initialized[$hash] = true;
        } else {
            foreach ($map->getControls() as $control) {
                $encoder->encodeReference($control);
            }

            foreach ($map->getLayers() as $layer) {
                $encoder->encodeReference($layer);
            }

            $output->append($this->encodeMethodCalls($map->getMethodCalls(), $encoder));
        }
    }
public function encodeMap(Map $map, Encoder $encoder)
    {
        $output = $encoder->getOutput();
        $hash   = spl_object_hash($map);

        if (!isset($this->initialized[$hash])) {
            $output->prepend(
                sprintf(
                    '%s = L.map(%s);',
                    $encoder->encodeReference($map),
                    $encoder->encodeArguments(array($map->getElementId(), $map->getOptions()))
                )
            );

            $this->initialized[$hash] = true;
        } else {
            foreach ($map->getControls() as $control) {
                $encoder->encodeReference($control);
            }

            foreach ($map->getLayers() as $layer) {
                $encoder->encodeReference($layer);
            }

            $output->append($this->encodeMethodCalls($map->getMethodCalls(), $encoder));
        }
    }
public function encodeMap ( Map $ map , Encoder $ encoder ) { $ output = $ encoder -> getOutput ( ) ; $ hash = spl_object_hash ( $ map ) ; if ( ! isset ( $ this -> initialized [ $ hash ] ) ) { $ output -> prepend ( sprintf ( '%s = L.map(%s);' , $ encoder -> encodeReference ( $ map ) , $ encoder -> encodeArguments ( array ( $ map -> getElementId ( ) , $ map -> getOptions ( ) ) ) ) ) ; $ this -> initialized [ $ hash ] = true ; } else { foreach ( $ map -> getControls ( ) as $ control ) { $ encoder -> encodeReference ( $ control ) ; } foreach ( $ map -> getLayers ( ) as $ layer ) { $ encoder -> encodeReference ( $ layer ) ; } $ output -> append ( $ this -> encodeMethodCalls ( $ map -> getMethodCalls ( ) , $ encoder ) ) ; } }
Compile a map.

@param Map     $map     The map.
@param Encoder $encoder The builder.

@return void
Compile a map .