\GetLatLngFromGoogleUsingAddress
Geocode an address-string to a set of coordinates using Google's free geocoding services.
see: http://code.google.com/apis/maps/documentation/geocoding/index.html
CHECKS IF CURL / file_get_contents is available
Requirements: allow_url_fopen = on
- Author: Ingo Schomme and Nicolaas Francken
Synopsis
class GetLatLngFromGoogleUsingAddress
extends Object
{
- // members
- private static Boolean $debug = false;
- private static String $geocode_url = "https://maps.googleapis.com/maps/api/geocode/json?address=%s";
- private static array $additional_params = ;
- private static boolean $default_to_first_result = true;
- private static boolean $server_side_available = true;
- private static string $google_client_id = "";
- private static string $alternative_google_map_api_key = "";
- protected static array $google_2_ss_translation_array = ;
- // methods
- public static array get_placemark_as_array()
- protected static Object get_placemark()
- protected static Object get_geocode_obj()
- private static Array json_decoder()
- private static Array json_encoder()
- protected static Array google_2_ss()
Hierarchy
Extends
- Object
Tasks
Line | Task |
---|---|
21+ | Implement CURL with fopen fallback |
21+ | Implement client-side selection when multiple results are found (through validation-errors and javasript) |
Members
private
- $additional_params
—
array
Additional data to send to the Google Server - $alternative_google_map_api_key
—
string
alternative api key. - $debug
—
Boolean
For debugging. - $default_to_first_result
—
boolean
default user to first result that is returned. - $geocode_url
—
String
location for API - $google_client_id
—
string
alternative to api key - $server_side_available
—
boolean
tells you if CURL / file_get_contents is available we recommend you set to true , unless it is not sure if CURL is available
protected
-
$google_2_ss_translation_array
GOOGLE: street_address indicates a precise street address.
Methods
private
protected
- get_geocode_obj() — Get geocode from google.
- get_placemark() — Get first placemark from google, or return false.
- google_2_ss() — Converts Google Response INTO Silverstripe Google Map Array that can be saved into a GoogleMapLocationsObject
public
- get_placemark_as_array() — Get first placemark as flat array