Descrizione

Il wpforms_geolocation_map_zoom viene utilizzato per modificare il livello di zoom predefinito della mappa utilizzata nel file Geolocalizzazione addon.

Parametri

$zoom
(int) Il livello di zoom per la vista della voce.
$contesto
(int) Il livello di zoom per la vista del modulo.

Fonte

wpforms-geolocation/src/Map.php

Ulteriori informazioni

Il wpforms_geolocation_map_zoom può essere utilizzato per modificare il livello di zoom predefinito della mappa mostrata nella voce e nel modulo utilizzando il filtro Geolocalizzazione addon.

Esempio

/**
 * 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 );

Documentazione di riferimento: Come modificare la posizione predefinita per l'addon di geolocalizzazione