Does Google maps api fit with offset?

I have a google map with user control over it, covering 35% of the correct area:

  var myControl = document.getElementById('tireshopsPickerList');
  map.controls[google.maps.ControlPosition.RIGHT_CENTER].push(myControl);

When the user enters the address in the input field above the map, I geocode it and build a list of the nearest stores; I place markers and then currently use the first 5 stores that are visible on the map that are suitable for protection:

      var fullBounds = new google.maps.LatLngBounds();
      _.each(
        _.first(shops, 5),
        function (s) {
          var point = new google.maps.LatLng(
            parseFloat(s.shop.latitude),
            parseFloat(s.shop.longitude)
            );

          fullBounds.extend(point);
        });
      map.fitBounds(fullBounds);

The problem is that some of the markers are under user control and are not visible. I was wondering if there is a way to show the map in order to make 5 stores visible not only on the entire map, but also on a specific area of ​​the map. Is it possible?

+4
source share

Source: https://habr.com/ru/post/1538039/


All Articles