I've successfully integrated the Geocomplete jquery plugin on a wordpress site. My issue is that I cannot limit the autosuggestion results to neighbourhood or sublocality. I've revised the Google Place types thoroughly but my results are always just the same. I know I'm doing something incorrectly somewhere. Here's what I have so far:
add_action( 'wp_head', 'add_geocomplete_script' );
function add_geocomplete_script() {
?>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCJ1Bgyx1jSN3aRFB3uUkLLntXCONZfOyM&libraries=places"></script>
<script src="<?php echo get_stylesheet_directory_uri() ?>/js/jquery.geocomplete.js"></script>
<script src="<?php echo get_stylesheet_directory_uri() ?>/js/logger.js"></script>
<?php
}
function woocommerce_checkout_autocomplete(){
?>
<script>
jQuery(document).ready(function() {
var options = {
//types: ['(cities)'],
//types: ['sublocality'],
//componentTypes: ['neighborhood'],
types: ["geocode", "sublocality"],
country: 'za'
};
jQuery("#billing_myfield8").geocomplete(options);
jQuery("#billing_myfield8").on("keyup", function() {
//jQuery("#billing_myfield8").trigger("geocode");
console.log('You typed in the input box');
});
});
</script>
<?php
}
add_action( 'wp_footer', 'woocommerce_checkout_autocomplete' );
With the above code I'm still able to search for an address, eg. 112 Nowhere Street. It doesn't filter the results.