Documentation

CRM_Utils_Geocode_Google
in package

Class that uses google geocoder

Table of Contents

Properties

$_server  : string
Server to retrieve the lat/long
$_uri  : string
Uri of service.

Methods

format()  : bool
Function that takes an address object and gets the latitude / longitude for this address. Note that at a later stage, we could make this function also clean up the address into a more valid format
getCoordinates()  : array<string|int, mixed>
makeRequest()  : array<string|int, mixed>

Properties

$_server

Server to retrieve the lat/long

protected static string $_server = 'maps.googleapis.com'

$_uri

Uri of service.

protected static string $_uri = '/maps/api/geocode/xml?sensor=false&address='

Methods

format()

Function that takes an address object and gets the latitude / longitude for this address. Note that at a later stage, we could make this function also clean up the address into a more valid format

public static format(array<string|int, mixed> &$values[, bool $stateName = FALSE ]) : bool
Parameters
$values : array<string|int, mixed>
$stateName : bool = FALSE
Return values
bool

true if we modified the address, false otherwise

getCoordinates()

public static getCoordinates(string $address) : array<string|int, mixed>
Parameters
$address : string

Plain text address

Tags
throws
GuzzleException
Return values
array<string|int, mixed>

makeRequest()

private static makeRequest(string $add) : array<string|int, mixed>
Parameters
$add : string

Url-encoded address

Tags
throws
GuzzleException
Return values
array<string|int, mixed>

An array of values with the following possible keys: geo_code_error: String error message geo_code_1: Float latitude geo_code_2: Float longitude request_xml: SimpleXMLElement parsed xml from geocoding API


        
On this page

Search results