Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Google Maps API from scrolling to a grey area

Tags:

google-maps

In an application I'm building, the Google Maps API takes up most (if not all) of the screen. However, during testing I've discovered that a user can drag the map down far enough so that the map isn't displayed anymore, and all thats left is a grey background.

How can I stop this? I have set a minZoom but this only solves the problem for when the page is loaded and the user wants to zoom out.

like image 742
mickburkejnr Avatar asked Nov 29 '22 02:11

mickburkejnr


1 Answers

new solution

new google.maps.Map(document.getElementById('map'), {
restriction: {
    latLngBounds: {
        north: 85,
        south: -85,
        west: -180,
        east: 180
    }
},
});
like image 118
Felipe Fetzner Avatar answered Dec 05 '22 18:12

Felipe Fetzner