ご注意!

この記事には PHP コードが含まれており、開発者を対象としています。このコードは便宜上提供していますが、コードのカスタマイズやサードパーティの開発についてはサポートを提供していません。

追加のガイダンスについては、WPBeginner の カスタムコードの追加方法に関するチュートリアル を参照してください。

閉じる

説明

wpforms_geolocation_map_zoomフィルターは、Geolocationアドオンで使用されるマップのデフォルトのズームレベルを変更するために使用されます。

パラメーター

$zoom
(int) エントリ表示用のズームレベル。
$context
(int) フォーム表示用のズームレベル。

ソース

wpforms-geolocation/src/Map.php

詳細情報

wpforms_geolocation_map_zoomフィルターは、Geolocationアドオンを使用して、エントリおよびフォームに表示されるマップのデフォルトのズームレベルを変更するために使用できます。

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

ドキュメントリファレンス:Geolocationアドオンのデフォルトの場所を変更する方法