Monday, 24 April 2023

Google Auto Complete setBounds not a function error

I am using googles address autocomplete and in the console it is throwing an error.

caught TypeError: autocomplete.setBounds is not a function

the code is:

function geolocate() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var geolocation = new google.maps.LatLng(
        position.coords.latitude, position.coords.longitude);
      var circle = new google.maps.Circle({
        center: geolocation,
        radius: position.coords.accuracy
      });
      autocomplete.setBounds(circle.getBounds());
    });
  }

Is there a reason why setBounds would not work anymore? It used to function properly without erroring.

http://jsfiddle.net/bobrierton/89nqv5v5/



from Google Auto Complete setBounds not a function error

No comments:

Post a Comment