Google API does not auto complete in bank

Asked

Viewed 39 times

0

I’m using the Google API on an html page to get the user’s location. When the user type EX: Bon Street ( will appear options for him, there for example he clicks on Bonnard Street ... ) in the text field fills all the missing content. But when we record and look at the bank, only Bon Street appears in place of Bonnard Street.

Script

function initAutocomplete() {
                    var map = new google.maps.Map(document.getElementById('map'), {
                      center: {lat: -33.8688, lng: 151.2195},
                      zoom: 13,
                      mapTypeId: 'roadmap'
                    });

                    // Create the search box and link it to the UI element.
                    var input = document.getElementById('pac-input');
                    var searchBox = new google.maps.places.SearchBox(input);
                    map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);

                    // Bias the SearchBox results towards current map's viewport.
                    map.addListener('bounds_changed', function() {
                      searchBox.setBounds(map.getBounds());
                    });

                    var markers = [];
                    // Listen for the event fired when the user selects a prediction and retrieve
                    // more details for that place.
                    searchBox.addListener('places_changed', function() {
                      var places = searchBox.getPlaces();

                      if (places.length == 0) {
                        return;
                      }

                      // Clear out the old markers.
                      markers.forEach(function(marker) {
                        marker.setMap(null);
                      });
                      markers = [];

                      // For each place, get the icon, name and location.
                      var bounds = new google.maps.LatLngBounds();
                      places.forEach(function(place) {
                        if (!place.geometry) {
                          console.log("Returned place contains no geometry");
                          return;
                        }
                        var icon = {
                          url: place.icon,
                          size: new google.maps.Size(71, 71),
                          origin: new google.maps.Point(0, 0),
                          anchor: new google.maps.Point(17, 34),
                          scaledSize: new google.maps.Size(25, 25)
                        };

                        // Create a marker for each place.
                        markers.push(new google.maps.Marker({
                          map: map,
                          icon: icon,
                          title: place.name,
                          position: place.geometry.location
                        }));

                        if (place.geometry.viewport) {
                          // Only geocodes have viewport.
                          bounds.union(place.geometry.viewport);
                        } else {
                          bounds.extend(place.geometry.location);
                        }
                      });
                      map.fitBounds(bounds);
                    });
                  }

HTML :

<input id="pac-input" ng-model="codPC" class="controls" type="text" placeholder="Endereço...">
<p></p>
<div id="map"></div>

1 answer

0


The problem was that he could not get the full name, so we created a script by placing the following command

Document.getElementById("Pac-input"). value;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.