yf_form2_google_maps class

Fileplugins/form2/classes/form2/yf_form2_google_maps.class.php
Use_class('form2_google_maps', 'classes/form2/')

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 1

google_maps

public function google_maps($name = '', $desc = '', $extra = [], $replace = [], $form = null)
    public function google_maps($name = '', $desc = '', $extra = [], $replace = [], $form = null)
    {
        if (is_array($desc)) {
            $extra += $desc;
            $desc = '';
        }
        if ( ! is_array($extra)) {
            $extra = [];
        }

        asset('google-maps-api');

        $extra['name'] = ($extra['name'] ?? null) ?: ($name ?: 'map');
        $extra['markers_limit'] = ($extra['markers_limit'] ?? null) ?: 5;
        $extra['start_zoom'] = ($extra['start_zoom'] ?? null) ?: 5;
        $extra['desc'] = $form->_prepare_desc($extra, $desc);
        $func = function ($extra, $r, $form) {
            $form->_prepare_inline_error($extra);
            // Compatibility with filter
            $start_lat = 49;
            $start_lng = 32;
            $replace = [
                'start_lat' => $start_lat,
                'start_lng' => $start_lng,
                'start_zoom' => $extra['start_zoom'],
                'markers_limit' => $extra['markers_limit'],
                'name' => $extra['name'],
                'value' => $r[$extra['name']],
            ];
            if ($extra['disable_edit_mode']) {
                $body = tpl()->parse('form2/google_maps_view', $replace);
            } else {
                $body = tpl()->parse('form2/google_maps', $replace);
            }
            return $form->_row_html($body, $extra, $r);
        };
        if ($form->_chained_mode) {
            $form->_body[] = ['func' => $func, 'extra' => $extra, 'replace' => $replace, 'name' => __FUNCTION__];
            return $form;
        }
        return $func($extra, $replace, $form);
    }