PHP code example of nolazybits / propel2-geocodable-behavior
1. Go to this page and download the library: Download nolazybits/propel2-geocodable-behavior 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/ */
nolazybits / propel2-geocodable-behavior example snippets
php
class MyObject extends BaseMyObject
{
// ...
/**
* {@inheritdoc}
*/
public function geocode()
{
if (null !== $result = parent::geocode()) {
if ($city = $result->getCity()) {
$this->setCity($city);
}
}
return $result;
}
}
xml
<behavior name="geocodable">
<parameter name="geocode_address" value="true" />
<parameter name="geocoder_api_key" value="<API_KEY>" />
</behavior>
xml
<behavior name="geocodable">
<parameter name="auto_update" value="true" />
<parameter name="latitude_column" value="latitude" />
<parameter name="longitude_column" value="longitude" />
<parameter name="type" value="DOUBLE" />
<parameter name="size" value="11" />
<parameter name="scale" value="8" />
<!-- IP-Based Geocoding -->
<parameter name="geocode_ip" value="false" />
<parameter name="ip_column" value="ip_address" />
<!-- Address-Based Geocoding -->
<parameter name="geocode_address" value="false" />
<parameter name="address_columns" value="street,locality,region,postal_code,country" />
<!-- Geocoder -->
<parameter name="geocoder_provider" value="\Geocoder\Provider\YahooProvider" />
<parameter name="geocoder_adapter" value="\Geocoder\HttpAdapter\CurlHttpAdapter" />
<parameter name="geocoder_api_key" value="false" />
<parameter name="geocoder_api_key_provider" value="false" />
</behavior>