| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente |
| informatique:wordpress:acf:acf-openstreetmap-field [24/12/2024 11:08] – cyrille | informatique:wordpress:acf:acf-openstreetmap-field [25/12/2024 21:56] (Version actuelle) – [different geocoders] cyrille |
|---|
| |
| * [[https://github.com/mcguffin/acf-openstreetmap-field/issues/71|Other library nominatim to geocoder]] | * [[https://github.com/mcguffin/acf-openstreetmap-field/issues/71|Other library nominatim to geocoder]] |
| | |
| | Étude ... |
| | <code javascript> |
| | // 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() |
| | |
| | </code> |
| | |
| | Les geocoders de [[https://github.com/perliedman/leaflet-control-geocoder|leaflet-control-geocoder]] n'ont pas tous l'option ''htmlTemplate'' :-( |
| | * [[https://www.liedman.net/leaflet-control-geocoder/docs/interfaces/geocoders.NominatimOptions.html#htmltemplate|Nominatim htmlTemplate]] |
| | * [[https://www.liedman.net/leaflet-control-geocoder/docs/interfaces/geocoders.PhotonOptions.html#htmltemplate|Photon htmlTemplate]] |
| | |
| | Geocoder options |
| | * [[https://www.liedman.net/leaflet-control-geocoder/docs/classes/geocoders.Openrouteservice.html#options|Openrouteservice options]] |
| | * [[https://www.liedman.net/leaflet-control-geocoder/docs/interfaces/geocoders.PeliasOptions.html|PeliasOptions]] |
| | * [[https://www.liedman.net/leaflet-control-geocoder/docs/interfaces/geocoders.OpenCageOptions.html|OpenCageOptions]] |
| |
| ==== Surcharge de la Localisation du résultat ==== | ==== Surcharge de la Localisation du résultat ==== |
| |
| In ''include/ACFFieldOpenstreetmap/Core/Core.php'' | * Issue https://github.com/mcguffin/acf-openstreetmap-field/issues/128 |
| | * PR https://github.com/mcguffin/acf-openstreetmap-field/pull/129 |
| |
| Override geocode results format translation in wp-config | 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. |
| |
| <code> | Geocode results format are set with translation for localisation. But in some case we want specific formats. |
| 'address_format' => [ | |
| 'street' => defined('ACF_OSM_I18N_ADDR_STREET') | In ''wp-config.php'' we can override the 3 formats for the address like: |
| ? constant('ACF_OSM_I18N_ADDR_STREET') | |
| : __( '{building} {road} {house_number}' | <code php> |
| , 'acf-openstreetmap-field' ), | define('ACF_OSM_I18N_ADDR_STREET','{building} {house_number} {road}'); |
| 'city' => defined('ACF_OSM_I18N_ADDR_CITY') | define('ACF_OSM_I18N_ADDR_CITY','{village} {town} {city}'); |
| ? constant('ACF_OSM_I18N_ADDR_CITY') | define('ACF_OSM_I18N_ADDR_COUNTRY',''); |
| : __( '{postcode} {city} {town} {village} {hamlet}' | |
| , 'acf-openstreetmap-field' ), | |
| 'country' => defined('ACF_OSM_I18N_ADDR_COUNTRY') | |
| ? constant('ACF_OSM_I18N_ADDR_COUNTRY') | |
| : __( '{state} {country}' | |
| , 'acf-openstreetmap-field' ) | |
| ] | |
| </code> | </code> |
| | |
| | Or with a filter in ''functions.php'' or somewhere else : |
| | |
| | <code php> |
| | add_filter('acf_osm_address_format', function($format){ |
| | $format['street'] = 'from filter: {building} {road} {house_number}' ; |
| | return $format ; |
| | } ); |
| | </code> |
| | |
| | ==== Set map view with zoom after geocoding ==== |
| | |
| | * https://github.com/mcguffin/acf-openstreetmap-field/issues/122 |
| | * @mcguffin closed this as completed in [[https://github.com/mcguffin/acf-openstreetmap-field/commit/648a42a86fb26bf216fdc7d2552bffbf8fcfa477|648a42a]] |
| | |
| | |
| |