I am completely new to Google Maps and am just creating my first map so that I can incorporate it into my website.
I am trying to limit the area that the user can m
Just for anyone who stumbles upon the now-outdated info on this page as I did, the maps API now provides a built-in way to restrict the map viewport bounds via the restriction property of the MapOptions interface, see docs here. This example restricts north-south panning from showing Antarctica:
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 20, lng: -52},
zoom: 3,
restriction: {latLngBounds:{north: 83.8, south: -57, west: -180, east: 180}}
});
}