public function renderAutocomplete(Autocomplete $autocomplete)
    {
        $this->jsonBuilder->reset();

        if ($autocomplete->hasTypes()) {
            $this->jsonBuilder->setValue('[types]', $autocomplete->getTypes());
        }

        if ($autocomplete->hasBound()) {
            $this->jsonBuilder->setValue('[bounds]', $autocomplete->getBound()->getJavascriptVariable(), false);
        }

        if ($autocomplete->hasComponentRestrictions()) {
            $this->jsonBuilder->setValue('[componentRestrictions]', $autocomplete->getComponentRestrictions());
        }

        if (!$this->jsonBuilder->hasValues()) {
            $this->jsonBuilder->setJsonEncodeOptions(JSON_FORCE_OBJECT);
        }

        return sprintf(
            '%s = new google.maps.places.Autocomplete(document.getElementById(\'%s\'), %s);'.PHP_EOL,
            $autocomplete->getJavascriptVariable(),
            $autocomplete->getInputId(),
            $this->jsonBuilder->build()
        );
    }
public function renderAutocomplete(Autocomplete $autocomplete)
    {
        $this->jsonBuilder->reset();

        if ($autocomplete->hasTypes()) {
            $this->jsonBuilder->setValue('[types]', $autocomplete->getTypes());
        }

        if ($autocomplete->hasBound()) {
            $this->jsonBuilder->setValue('[bounds]', $autocomplete->getBound()->getJavascriptVariable(), false);
        }

        if ($autocomplete->hasComponentRestrictions()) {
            $this->jsonBuilder->setValue('[componentRestrictions]', $autocomplete->getComponentRestrictions());
        }

        if (!$this->jsonBuilder->hasValues()) {
            $this->jsonBuilder->setJsonEncodeOptions(JSON_FORCE_OBJECT);
        }

        return sprintf(
            '%s = new google.maps.places.Autocomplete(document.getElementById(\'%s\'), %s);'.PHP_EOL,
            $autocomplete->getJavascriptVariable(),
            $autocomplete->getInputId(),
            $this->jsonBuilder->build()
        );
    }
public function renderAutocomplete ( Autocomplete $ autocomplete ) { $ this -> jsonBuilder -> reset ( ) ; if ( $ autocomplete -> hasTypes ( ) ) { $ this -> jsonBuilder -> setValue ( '[types]' , $ autocomplete -> getTypes ( ) ) ; } if ( $ autocomplete -> hasBound ( ) ) { $ this -> jsonBuilder -> setValue ( '[bounds]' , $ autocomplete -> getBound ( ) -> getJavascriptVariable ( ) , false ) ; } if ( $ autocomplete -> hasComponentRestrictions ( ) ) { $ this -> jsonBuilder -> setValue ( '[componentRestrictions]' , $ autocomplete -> getComponentRestrictions ( ) ) ; } if ( ! $ this -> jsonBuilder -> hasValues ( ) ) { $ this -> jsonBuilder -> setJsonEncodeOptions ( JSON_FORCE_OBJECT ) ; } return sprintf ( '%s = new google.maps.places.Autocomplete(document.getElementById(\'%s\'), %s);' . PHP_EOL , $ autocomplete -> getJavascriptVariable ( ) , $ autocomplete -> getInputId ( ) , $ this -> jsonBuilder -> build ( ) ) ; }
Renders the autocomplete.

@param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete.

@return string The JS output.
Renders the autocomplete .