Atenção!

Este artigo contém código PHP e destina-se a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Descrição

The wpforms_geolocation_map_zoom filter is used to alter the default zoom level of the map used in the Geolocation addon.

Parâmetros

$zoom
(int) The zoom level for the entry view.
$context
(int) The zoom level for the form view.

Fonte

wpforms-geolocation/src/Map.php

Mais Informações

The wpforms_geolocation_map_zoom filter can be used to alter the default zoom level of the map shown on the entry and in the form using the Geolocation addon.

Exemplo

/**
 * Alter default zoom level of the maps on entries and forms using the Geolocation addon.
 *
 * @link    https://wpforms.com/developers/wpforms_geolocation_map_zoom/
 *
 * @param   int  $zoom  The zoom level for the entry view.
 * @param   int  $zoom  The zoom level for the form view.
 *
 * @return  int
 */

function wpf_wpforms_geolocation_map_zoom( $zoom, $context ) {
   
       // This will change the zoom level while viewing the entry. 
       if ( 'entry' === $context ) {
          return 10;
       }
     
       // This will change the zoom level on the map that displays on the form above/under the Address field.
       if ( 'field' === $context ) {
          return 15;
       }
     
       return $zoom;
}
add_filter( 'wpforms_geolocation_map_zoom', 'wpf_wpforms_geolocation_map_zoom', 10, 2 );

Documentation Reference: How to Change Default Location for Geolocation Addon