Harsha M V
Harsha M V

Reputation: 54949

Google Maps v3 AutoComplete get the Suggestions

I am trying to use autocomplete in Google Maps. I am getting the results. but i want to college the results and feed it to my themes Autocomplete Plugin to make it look better. I am not able to get the list of the places as a modifiable variable array.

    var zoomLevel = 13;
    var lat = 13.00487;
    var lng = 77.576729;


    var mapOptions = {
        center: new google.maps.LatLng(lat, lng),
        zoom: zoomLevel,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById('map'), mapOptions);

    var input = document.getElementById('search-google-places');

    var options = {
  types: ['geocode']
    };

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

    var place = autocomplete.getPlace();
    console.log(place);

Upvotes: 0

Views: 2642

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117314

Request the autocompleteService directly instead of using a places.Autocomplete, the response will give you the predictions.

Upvotes: 1

Related Questions