Ionic - Google places and Autocomplete location

后端 未结 3 462
北恋
北恋 2020-12-08 14:51

I have work on the project on Ionic 2 and I have implemented the map so far, but I can not get out of that point. I needed to be shown the way I should go in order to add Go

3条回答
  •  清歌不尽
    2020-12-08 15:08

    If all you need is "google places object", then your code can be very simple like so:

    
        Search your city
        
    
    

    And in my code:

    ionViewWillEnter() {
       // Google Places API auto complete
       let input = document.getElementById('googlePlaces').getElementsByTagName('input')[0];
       let autocomplete = new google.maps.places.Autocomplete(input, {types: ['geocode']});
       google.maps.event.addListener(autocomplete, 'place_changed', () => {
         // retrieve the place object for your use
         let place = autocomplete.getPlace();
       });
    }
    

提交回复
热议问题