Renders the map input

@param      $value
@param bool $isSettings

@return string
@throws InvalidConfigException
14235
private function _renderMap ($value, $isSettings = false)
	{
		$view = Craft::$app->getView();

		$containerId = $this->id . '-container';
		$vueContainerId = $view->namespaceInputId($containerId);
		$view->registerJsFile('https://polyfill.io/v3/polyfill.min.js?flags=gated&features=default%2CIntersectionObserver%2CIntersectionObserverEntry');
		$view->registerAssetBundle(MapAsset::class);
		$view->registerJs('new Vue({ el: \'#' . $vueContainerId . '\' });');
		$view->registerTranslations('simplemap', [
			'Search for a location',
			'Clear',
			'Name / Number',
			'Street Address',
			'Town / City',
			'Postcode',
			'County',
			'State',
			'Country',
			'Latitude',
			'Longitude',
		]);

		/** @var Settings $settings */
		$settings = SimpleMap::getInstance()->getSettings();

		$country = $this->country;
		// Convert ISO2 to ISO3 for Here autocomplete
		if ($country && $settings->geoService === GeoEnum::Here)
			$country = GeoService::$countriesIso3[$country];

		$opts = [
			'config' => [
				'isSettings' => $isSettings,

				'name'        => $view->namespaceInputName($this->handle),
				'country'     => $country,
				'hideSearch'  => (bool) $this->hideSearch,
				'hideMap'     => (bool) $this->hideMap,
				'hideAddress' => (bool) $this->hideAddress,
				'showLatLng'  => (bool) $this->showLatLng,

				'mapTiles' => $settings->mapTiles,
				'mapToken' => GeoService::getToken(
					$settings->mapToken,
					$settings->mapTiles
				),

				'geoService' => $settings->geoService,
				'geoToken'   => GeoService::getToken(
					$settings->geoToken,
					$settings->geoService
				),

				'locale' => Craft::$app->locale->getLanguageID(),
			],

			'value' => [
				'address' => $value->address,
				'lat'     => $value->lat,
				'lng'     => $value->lng,
				'zoom'    => $value->zoom,
				'parts'   => $value->parts,
			],

			'defaultValue' => [
				'address' => null,
				'lat'     => $this->lat,
				'lng'     => $this->lng,
				'zoom'    => $this->zoom,
				'parts'   => null,
			],
		];

		// Map Services
		// ---------------------------------------------------------------------

		if (strpos($settings->mapTiles, 'google') !== false)
		{
			$view->registerJsFile(
				'https://maps.googleapis.com/maps/api/js?libraries=places&key=' .
				$settings->mapToken
			);
		}
		elseif (strpos($settings->mapTiles, 'mapkit') !== false)
		{
			$view->registerJsFile(
				'https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js'
			);
		}

		// Geo Services
		// ---------------------------------------------------------------------

		if ($settings->geoService === GeoEnum::GoogleMaps)
		{
			$view->registerJsFile(
				'https://maps.googleapis.com/maps/api/js?libraries=places&key=' .
				$settings->geoToken
			);
		}
		elseif ($settings->geoService === GeoEnum::AppleMapKit)
		{
			$view->registerJsFile(
				'https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js'
			);
		}

		$options = preg_replace(
			'/\'/',
			'&#039;',
			json_encode($opts)
		);

		return '<div id="' . $containerId . '"><simple-map options=\'' . $options . '\'></simple-map></div>';
	}
149555
public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = array();

        foreach ($fieldSettings as $settingKey => $settingValue) {
            switch ($settingKey) {
                case 'isMultiple':
                    if (!is_bool($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'bool',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'options':
                    if (!is_array($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'multilingualOptions':
                    if (!is_array($settingValue) && !is_array(reset($settingValue))) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                default:
                    $validationErrors[] = new ValidationError(
                        "Setting '%setting%' is unknown",
                        null,
                        array(
                            '%setting%' => $settingKey,
                        ),
                        "[$settingKey]"
                    );
            }
        }

        return $validationErrors;
    }
216017
protected function normalizeValue($value)
    {
        if (false === $value) {
            return $value;
        }

        $value = $this->remapXml($value);

        $normalized = array();
        foreach ($value as $name => $val) {
            if (isset($this->children[$name])) {
                $normalized[$name] = $this->children[$name]->normalize($val);
                unset($value[$name]);
            } elseif (!$this->removeExtraKeys) {
                $normalized[$name] = $val;
            }
        }

        // if extra fields are present, throw exception
        if (count($value) && !$this->ignoreExtraKeys) {
            $msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath());
            $ex = new InvalidConfigurationException($msg);
            $ex->setPath($this->getPath());

            throw $ex;
        }

        return $normalized;
    }
166345
public static function encode($value, int $options = null) : string
    {
        if ($options) {
            $encoded = json_encode($value, $options);
        } else {
            $encoded = json_encode($value);
        }

        if (!is_string($encoded)) {
            throw new \InvalidArgumentException(sprintf(
                "Json encode failed (%s) with '%s' and type '%s'",
                json_last_error(),
                json_last_error_msg(),
                gettype($encoded)
            ));
        }

        return $encoded;
    }
47846
private function renderForCheckbox(PropertyInterface $property, $value, &$isRendered)
    {
        $evaluation = $property->getExtra();

        if ((true === $isRendered) || $evaluation['multiple'] || !('checkbox' === $property->getWidgetType())) {
            return $value;
        }

        $isRendered = true;

        return !empty($value)
            ? $this->translate('MSC.yes', 'contao_default')
            : $this->translate('MSC.no', 'contao_default');
    }
81665
public function renderValue($value, array $options = []): string
    {
        $object = isset($options['object']) ? $options['object'] : null;
        $column = isset($options['column']) ? $options['column'] : null;
        $attributeCode = isset($options['attribute']) ? $options['attribute'] : null;
        if ($column instanceof Column && null === $attributeCode) {
            $attributeCode = $column->getPropertyPath();
        }

        if ($object instanceof DataInterface && $attributeCode) {
            try {
                $attribute = $object->getFamily()->getAttribute($attributeCode);
            } catch (\Exception $e) {
                // do nothing, it's okay
                return $this->parent->renderValue($value, $options);
            }
            $formOptions = $attribute->getFormOptions();
            if (!isset($formOptions['choices'])
                || !\in_array($attribute->getType()->getCode(), $this->choiceTypes, true)
            ) {
                return $this->parent->renderValue($value, $options);
            }
            $key = array_search($value, $formOptions['choices'], true);
            if (false !== $key) {
                $translationDomain = null;
                if (array_key_exists('choice_translation_domain', $formOptions)) {
                    $translationDomain = $formOptions['choice_translation_domain'];
                }
                if (false === $translationDomain) {
                    return $key;
                }

                return $this->translator->trans($key, [], $translationDomain);
            }
        }

        return $this->parent->renderValue($value, $options);
    }
200688
public function setValue($value)
    {
        if ('checkbox' === $this->type && false === $value) {
            // uncheck
            $this->value = null;
        } elseif ('checkbox' === $this->type && true === $value) {
            // check
            $this->value = $this->options[0]['value'];
        } else {
            if (is_array($value)) {
                if (!$this->multiple) {
                    throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name));
                }

                foreach ($value as $v) {
                    if (!$this->containsOption($v, $this->options)) {
                        throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->availableOptionValues())));
                    }
                }
            } elseif (!$this->containsOption($value, $this->options)) {
                throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->availableOptionValues())));
            }

            if ($this->multiple) {
                $value = (array) $value;
            }

            if (is_array($value)) {
                $this->value = $value;
            } else {
                parent::setValue($value);
            }
        }
    }
652212
public static function type_serialize($var, array $settings)
	{
		$var = serialize($var);

		if (array_key_exists('character_maximum_length', $settings))
		{
			$length  = intval($settings['character_maximum_length']);
			if ($length > 0 and strlen($var) > $length)
			{
				throw new InvalidContentType('Value could not be serialized, exceeds max string length for field.');
			}
		}

		return $var;
	}
533400
public function setStyle($value)
    {
        if (!ZoomControlStyle::getIsValid($value)) {
            throw new InvalidConfigException('Unknown "style" value');
        }

        $this->options['style'] = new JsExpression($value);
    }
439620
static public function kind($name, $value=null, $settings=[])
    {
        if (strpos($name, '[') === false) {
            $kind_type = $name;
            $name = '_kinds[' . $name . '][]';
        } else {
            $kind_type = preg_replace('/_(kinds\[)?(\w+)\]?\[\]/', '${2}', $name);
        }
        $settings = static::formatSettings($settings);
        $form_type = isset($settings['form_type']) ? trim($settings['form_type']) : 'checkbox_group';
        
        if ($form_type === 'modal') {
            $modal_url = isset($setting['modal_url']) ? $setting['modal_url'] : 'common/data/select/kind?kind_type=' . $kind_type;
            $settings['modal_url'] = Ioc::url($modal_url);
            $str = static::select($name, $value, $settings);
        } elseif ($form_type === 'select') {
            $str = static::select($name, $value, $settings);
        } else {
            $str = static::checkbox_group($name, $value, $settings);
        }
        
        return $str;
    }
101774
protected function processConfigVariables($value, $prefix = null)
    {
        if ($prefix && !preg_match('~^[a-z0-9._-]*$~i', $prefix)) {
            throw new exception\InvalidArgumentException('Invalid config var prefix: ' . $prefix);
        }

        if ($prefix) {
            // dots should be literal in regex
            $prefix = strtr($prefix, '.', '\\.');
        }

        $config = $this;
        $value = preg_replace_callback("~{{({$prefix}[a-z0-9._-]+)}}~i", function($match) use ($config) {
            return (string)$config->getConfigValue($match[1], '');
        }, $value);

        return $value;
    }
1316573
public function setStyle($value)
    {
        if (!ScaleControlStyle::getIsValid($value)) {
            throw new InvalidConfigException('Unknown "style" value');
        }

        $this->options['style'] = new JsExpression($value);
    }
1292024
public function setValue($value) {
        if ($value !== null) {
            if ($this->isIncremental() && ! is_numeric($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non numeric value "%s" on incremental option "%s".',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }

            if ($this->isBoolean() && ! is_bool($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non boolean value "%s" on boolean option "%s".',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }

            if ($this->isSingle() && ! is_scalar($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non scalar value "%s" on option "%s" ' .
                    'that expects one scalar value.',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }

            if ($this->isMultiple() && ! is_array($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non array value "%s" on option "%s" ' .
                    'that expects multiple values.',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
430379
public function serialize($value) : string
    {
        if (!is_numeric($value)) {
            throw InvalidValueException::valueDoesNotMatchType($this, $value);
        }

        return (string) (float) $value;
    }
265641
protected function renderTypeCollection($value, $presentation)
    {
        $baseType = $this->render($value->getBaseType(), $presentation);
        $keyTypes = $this->render($value->getKeyTypes(), $presentation);
        $types = $this->render($value->getTypes(), $presentation);

        $arguments = [];
        if ($keyTypes) {
            $arguments[] = implode('|', $keyTypes);
        }

        $arguments[] = implode('|', $types);

        if ($value->getName() === 'array' && count($value->getKeyTypes()) === 0) {
            $typeString = (count($types) > 1) ? '(' . reset($arguments) . ')' : reset($arguments);
            $collection = $typeString . '[]';
        } else {
            $collection = ($baseType ?: $value->getName()) . '&lt;' . implode(',', $arguments) . '&gt;';
        }

        return $collection;
    }
884549
private function assertBoolean($key, $value)
    {
        if (!is_bool($value) && null !== $value) {
            throw new InvalidConfigException(sprintf(
                'The config key "%s" must be a bool. Got: %s',
                $key,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }
    }
367287
public function sanitizeSetting($value)
    {
        $keys = $this->repository()->getSettings()->collapse()->map(function ($setting) {
            /** @var FieldTypeInterface $setting */
            return $setting->getName();
        });

        $settingName = $keys->slice($this->offset, 1)->first();
        $lastSetting = $this->repository()->getSettings()->collapse()->last();
        $data = collect($_POST);

        if ($this->offset > $keys->count() - 1) {
            if (empty($value)) {
                return '';
            }

            // Sanitize is called one more time with a valid value.
            // Let's get the $settingName based on the given value
            // as we can't rely anymore on the offset.
            $settingName = $data->search($value, true);

            if (! $settingName) {
                return '';
            }

            // Let's add a "fake" error to avoid duplicate success messages.
            $this->errors++;
        }

        $setting = $this->repository()->getSettingByName($settingName);

        $validator = $this->validator->make(
            $data->all(),
            [$setting->getName() => $setting->getOption('rules')],
            $this->getSettingMessages($setting),
            $this->getSettingPlaceholder($setting)
        );

        // Update setting offset.
        $this->offset++;

        /** @var Validator $validator */
        if ($validator->fails()) {
            $this->errors++;

            add_settings_error(
                $this->getSlug(),
                $setting->getName(),
                $validator->getMessageBag()->first($setting->getName()),
                'error'
            );

            return '';
        }

        if ($settingName === $lastSetting->getName() && ! $this->errors) {
            add_settings_error(
                $this->getSlug(),
                'settings_updated',
                __('Settings saved.'),
                'updated'
            );
        }

        return $value;
    }