@@ -556,6 +556,30 @@ class Map {
556
556
*/
557
557
private $ clustering_options = array ();
558
558
559
+ /**
560
+ * Places flag, places required for Autocomplete
561
+ * @var bool
562
+ */
563
+ private $ places = false ;
564
+
565
+ /**
566
+ * Places input id
567
+ *
568
+ * This will hold the id of the input to bind the Autocomplete to
569
+ *
570
+ * @var string
571
+ */
572
+ private $ autocomplete_id ;
573
+
574
+ /**
575
+ * AUtocomplete options
576
+ *
577
+ * array of options to be passed to the Autocomplete constructor
578
+ *
579
+ * @var array
580
+ */
581
+ private $ autocomplete_options = array ();
582
+
559
583
/**
560
584
* Loading content
561
585
*
@@ -662,6 +686,10 @@ public function __construct( array $options=null ) {
662
686
case 'compress_output ' :
663
687
$ option_val ? $ this ->enableCompressedOutput () : $ this ->disableCompressedOutput ();
664
688
break ;
689
+ case 'autocomplete ' :
690
+ $ this ->enablePlaces ($ option_val );
691
+ break ;
692
+
665
693
}
666
694
}
667
695
}
@@ -2133,6 +2161,15 @@ function getMapJS() {
2133
2161
$ this ->adsense_publisher_id
2134
2162
);
2135
2163
}
2164
+
2165
+ if ( $ this ->autocomplete_id )
2166
+ {
2167
+ $ output .= <<<EEE
2168
+ this.ac_input = document.getElementById(' {$ this ->autocomplete_id }');
2169
+ this.ac_options = {$ this ->phpToJs ($ this ->autocomplete_options )};
2170
+ this.autocomplete = new google.maps.places.Autocomplete(this.ac_input, this.ac_options);
2171
+ EEE ;
2172
+ }
2136
2173
2137
2174
if ( $ this ->traffic_layer ) {
2138
2175
$ output .= "\tthis.traffic_layer = new google.maps.TrafficLayer(); \n\tthis.traffic_layer.setMap(this.map); \n\n" ;
@@ -2392,4 +2429,16 @@ function enableClustering( $clustering_js_file, $options = null ) {
2392
2429
$ this ->clustering_options = $ options ;
2393
2430
}
2394
2431
2395
- }
2432
+ function enablePlaces ($ options = array ())
2433
+ {
2434
+ if (!$ this ->places ) $ this ->libraries [] = 'places ' ;
2435
+ $ this ->places = true ;
2436
+
2437
+ if (isset ($ options ["id " ]))
2438
+ {
2439
+ $ this ->autocomplete_id = $ options ["id " ];
2440
+ unset($ options ["id " ]);
2441
+ $ this ->autocomplete_options = $ options ;
2442
+ }
2443
+ }
2444
+ }
0 commit comments