From 914c7e3afeb8e90872f139fab17f6f1bbdeb61b6 Mon Sep 17 00:00:00 2001 From: Brennan Date: Mon, 1 May 2017 23:44:07 -0500 Subject: [PATCH] Autocomplete-standalone Use google maps autocomplete with an input box without displaying a map. Usage: $this->googlemaps->autocomplete(); --- application/libraries/Googlemaps.php | 156 ++++++++++++++++++++++++++- 1 file changed, 155 insertions(+), 1 deletion(-) diff --git a/application/libraries/Googlemaps.php b/application/libraries/Googlemaps.php index 5f549f8..b2beb2b 100644 --- a/application/libraries/Googlemaps.php +++ b/application/libraries/Googlemaps.php @@ -2171,6 +2171,160 @@ function loadScript_'.$this->map_name.'() { return array('js'=>$this->output_js, 'html'=>$this->output_html, 'markers'=>$this->markersInfo); + } + function autocomplete() + { + $this->output_js = ''; + $this->output_js_contents = ''; + + if ($this->maps_loaded == 0) + { + if ($this->apiKey!="") + { + if ($this->https) { $apiLocation = 'https'; }else{ $apiLocation = 'http'; } + $apiLocation .= '://maps.googleapis.com/maps/api/js?key='.$this->apiKey.'&'; + } + else + { + if ($this->https) { $apiLocation = 'https://maps-api-ssl'; }else{ $apiLocation = 'http://maps'; } + $apiLocation .= '.google.com/maps/api/js?'; + } + $apiLocation .= 'sensor='.$this->sensor; + $libraries = array(); + if ($this->places!="") { array_push($libraries, 'places'); } + if (count($libraries)) { $apiLocation .= '&libraries='.implode(",", $libraries); } + if (!$this->loadAsynchronously) + { + $this->output_js .= ' + '; + } + } + if ($this->jsfile=="") { + $this->output_js .= ' + '; + } + } + } + + if ($this->jsfile=="") { + $this->output_js .= ' + //]]> + '; + } + return array('js'=>$this->output_js); + } function is_lat_long($input) @@ -2260,4 +2414,4 @@ function get_lat_long_from_address($address, $attempts = 0) } -?> \ No newline at end of file +?>