Point

This section will go over how to use the geocoded point class included with the geocoder field type.

This particular class is returned by the presenter's geocode method:

$point = $decorated->geocode();

And an example of using the below methods in Twig:

{{ entry.location.geocode.state() }}

GeocoderFieldTypePoint::getResult()

The getResult returns the entire result array from Google's geocoding service.

Returns: array
Example
$result = $point->getResult();

GeocoderFieldTypePoint::address()

The address method returns the original input address used in the geocoder.

Returns: string
Example
$address = $point->address();

GeocoderFieldTypePoint::formatted()

The formatted method returns the formatted address string matched by the geocoder service.

Returns: string
Example
$match = $point->formatted();

GeocoderFieldTypePoint::route()

The route method returns the route component of the formatted address.

Returns: string
Example
$street = $point->route();

GeocoderFieldTypePoint::streetAddress()

The streetAddress method returns the street address (street number and route).

Returns: string
Example
$address1 = $point->streetAddress();

GeocoderFieldTypePoint::streetNumber()

The streetNumber method returns the street number of the formatted address.

Returns: string
Example
$house = $point->streetNumber();

GeocoderFieldTypePoint::city()

The city method returns the city component of the formatted address.

Returns: string
Example
$city = $point->city();

GeocoderFieldTypePoint::postalCode()

The postalCode method returns the postal code component of the formatted address.

Returns: string
Example
$zip = $point->postalCode();

GeocoderFieldTypePoint::state()

The state method returns the state component of the formatted address.

Returns: string
Example
$state = $point->state();

GeocoderFieldTypePoint::county()

The county method returns the county component of the formatted address.

Returns: string
Example
$county = $point->county();

GeocoderFieldTypePoint::country()

The country method returns the country name component of the formatted address.

Returns: string
Example
$country = $point->country();

GeocoderFieldTypePoint::countryCode()

The countryCode method returns the country code component of the formatted address.

Returns: string
Example
$country = $point->countryCode();

GeocoderFieldTypePoint::location()

The location method returns the location array component of the formatted address.

Returns: array
Example
$latitude = $point->location()['lat'];

GeocoderFieldTypePoint::latitude()

The latitude method returns the latitude component of the formatted address.

Returns: float
Example
$latitude = $point->latitude();

GeocoderFieldTypePoint::longitude()

The longitude method returns the longitude component of the formatted address.

Returns: float
Example
$longitude = $point->longitude();

GeocoderFieldTypePoint::point()

The point method returns a geometric Point instance to be used with the query builder if needed.

Returns: \Anomaly\GeocoderFieldType\Spatial\Point
Example
$location = $model->whereDistance('address', $geocoder->point(), '25 mi')->get();