Get street view / borders

On my website, I received a Google Maps autocomplete field that allows the user to select a location (for example, city or street).

As soon as the user selects an address, I automatically set the borders of the map to the borders of the location. For example, if the location is a large city, the borders will be reduced quite strongly, while they will be increased if the user enters a small street.

I want the whole place to be covered within the border - so if it is a long street, then ENTIRE street should be within the borders of the map.

Here is the code I'm using:

google.maps.event.addListener(autocomplete, 'place_changed', function () {
    var address = autocomplete.getPlace();
    if (address && address.geometry && address.geometry.location) {
        centerCoord = address.geometry.location;
        map.setCenter(new google.maps.LatLng(centerCoord.lat(), centerCoord.lng()));
        if (address.geometry.viewport) {
            map.fitBounds(address.geometry.viewport);
        } else {
            //this happens when inputting a street - no viewport or bounds are returned. How do I get the entire bounds of the street?
        }
    }
});

The problem is that the API does not seem to return a viewport or border when entering a street. How can I get ratings in this case?

(, 16) , , .

JsFiddle, : https://jsfiddle.net/cy1o228e/5/.

, ​​ Rolighedsvej, Frederiksberg, Denmark, , .

+4

All Articles