Outils pour utilisateurs

Outils du site


informatique:wordpress:acf:acf-openstreetmap-field

acf-openstreetmap-field

Un plugin ACF pour intégrer une carte à partir d'OpenStreetMap et Leaflet.

Proposed changes

different geocoders

The plugin already use leaflet-control-geocoder so it miss the UI, decoding and storing stuff

Étude …

// plugin view
// in wp-content/plugins/acf-openstreetmap-field/src/js/lib/media/views/map-input.js
initGeocode() {
 geocoder_options = Object.assign({
  ...
  geocoder: L.Control.Geocoder.nominatim( nominatim_options )
 this.geocoder = L.Control.geocoder( geocoder_options )
 
// tests
// in wp-content/plugins/acf-openstreetmap-field/test/js/address.js
mapDrawCenter(){
 const geocoder      = L.Control.Geocoder.nominatim()

Les geocoders de leaflet-control-geocoder n'ont pas tous l'option htmlTemplate :-(

Geocoder options

Surcharge de la Localisation du résultat

In ‎include/ACFFieldOpenstreetmap/Core/Core.php override geocode results format translation with constants in wp-config.php or with acf_osm_address_format WP filter.

Geocode results format are set with translation for localisation. But in some case we want specific formats.

In wp-config.php we can override the 3 formats for the address like:

define('ACF_OSM_I18N_ADDR_STREET','{building} {house_number} {road}');
define('ACF_OSM_I18N_ADDR_CITY','{village} {town} {city}');
define('ACF_OSM_I18N_ADDR_COUNTRY','');

Or with a filter in functions.php or somewhere else :

add_filter('acf_osm_address_format', function($format){
	$format['street'] = 'from filter: {building} {road} {house_number}' ;
	return $format ;
} );

Set map view with zoom after geocoding

informatique/wordpress/acf/acf-openstreetmap-field.txt · Dernière modification : 25/12/2024 21:56 de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki