[+] Limit Google Maps address autocomplete by country, for example

You can add JS to your View that outputs a map with a distance filter so that the autocomplete has additional options, such as only recommending addresses that are cities in a particular country, for example.

( function( $ ) {
	$( document ).bind( 'js_event_wpv_addon_maps_init_map_completed', function(){

        var input = document.getElementById('toolset-maps-distance-center');
        var options = {
        types: ['(cities)'],
        componentRestrictions: {country: 'au'}
        };

        autocomplete = new google.maps.places.Autocomplete(input, options);

	});
})( jQuery );

This example shows only cities in Australia.

See the Google Maps documentation for more options: https://developers.google.com/maps/documentation/javascript/places-autocomplete


Let us know if this snippet is not working for you:

This snippet doesn’t work
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments