PHP code example of nr / fieldtypegeocoder
1. Go to this page and download the library: Download nr/fieldtypegeocoder library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nr / fieldtypegeocoder example snippets
// Fulltextsearch
$pages->find('geocoder*=Berl');
// Fulltextsearch
$pages->find('geocoder.formatted*=Berlin');
// Simplesearch
$pages->find('geocoder.properties.timezone=Europe/Berlin');
$pages->find('geocoder.properties.locality=Berlin');
$pages->find('geocoder.properties.lat>10');
$pages->find('geocoder.proximity=52.473758|13.402580, limit=3');
/**
* @see Geocoder::statusOn
* @see Geocoder::statusSingleResult
* @see Geocoder::statusMultipleResults
*/
$pages->find('geocoder.status=3'); // Status "On" and "SingleResult"
$pages->find('geocoder.status&2|4'); // Status "SingleResult" or "MultipleResults"
/** @global Wire $wire */
$wire->addHookBefore('FieldtypeGeocoder::getProvider', function(HookEvent $event) {
$fieldtype->apiKey; // or insert the key direct
$adapter = $event->argumentsByName('adapter');
$event->return = new \Geocoder\Provider\GoogleMaps\GoogleMaps($adapter, null, $apiKey);
$event->replace = true;
});
use Geocoder\Provider\Mapbox\Mapbox;
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;
/** @global Wire $wire */
$wire->addHookBefore('FieldtypeGeocoder::getProvider', function(HookEvent $event) {
$event->replace = true;
});
/**
* Manipulate the query
* For better results, add all mapbox types to the query
*/
$wire->addHookAfter('FieldtypeGeocoder::filterQuery', function(HookEvent $event) {
/** @var GeocodeQuery|ReverseQuery $query */
$query = $event->argumentsByName('query');
$query = $query->withData('location_type', Mapbox::TYPES);
$event->return = $query;
});