Address suggestions by google maps

前端 未结 3 641
谎友^
谎友^ 2021-02-10 19:15

Does somebody know if there is any way to reproduce an ajax suggestion box like http://maps.google.com/ have in my webpage using the google maps api?

The idea would be f

3条回答
  •  猫巷女王i
    2021-02-10 19:32

    There is an API example from Google.

    Make sure you load the places library:

    
    

    Next your javascript:

    var autocomplete;
    function initialize() {
        autocomplete = new google.maps.places.Autocomplete(
            document.getElementById('autocomplete'),
            { types: ['geocode'] }
        );
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    

    With HTML

    Also see https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

提交回复
热议问题