Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1109673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:16:27+00:00 2026-05-17T02:16:27+00:00

is it possible to limit Google map v3 to a certain area? I want

  • 0

is it possible to limit Google map v3 to a certain area? I want to allow displaying only some area (e.g. a country) and disallow the user to slide elsewhere. Also I want to restrict the zoom level – e.g. only between levels 6 and 9. And I want to use all the base map types.

Is there any way to achieve this?

I had a partial success with limiting zoom level by using StyledMap, but I succeeded only with restricting ROADMAP, I wasn’t able to limit zoom on other basic types this way.

Thanks for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:16:28+00:00Added an answer on May 17, 2026 at 2:16 am

    You can listen to the dragend event, and if the map is dragged outside the allowed bounds, move it back inside. You can define your allowed bounds in a LatLngBounds object and then use the contains() method to check if the new lat/lng center is within the bounds.

    You can also limit the zoom level very easily.

    Consider the following example: Fiddle Demo

    <!DOCTYPE html>
    <html> 
    <head> 
       <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
       <title>Google Maps JavaScript API v3 Example: Limit Panning and Zoom</title> 
       <script type="text/javascript" 
               src="http://maps.google.com/maps/api/js?sensor=false"></script>
    </head> 
    <body> 
       <div id="map" style="width: 400px; height: 300px;"></div> 
    
       <script type="text/javascript"> 
    
       // This is the minimum zoom level that we'll allow
       var minZoomLevel = 5;
    
       var map = new google.maps.Map(document.getElementById('map'), {
          zoom: minZoomLevel,
          center: new google.maps.LatLng(38.50, -90.50),
          mapTypeId: google.maps.MapTypeId.ROADMAP
       });
    
       // Bounds for North America
       var strictBounds = new google.maps.LatLngBounds(
         new google.maps.LatLng(28.70, -127.50), 
         new google.maps.LatLng(48.85, -55.90)
       );
    
       // Listen for the dragend event
       google.maps.event.addListener(map, 'dragend', function() {
         if (strictBounds.contains(map.getCenter())) return;
    
         // We're out of bounds - Move the map back within the bounds
    
         var c = map.getCenter(),
             x = c.lng(),
             y = c.lat(),
             maxX = strictBounds.getNorthEast().lng(),
             maxY = strictBounds.getNorthEast().lat(),
             minX = strictBounds.getSouthWest().lng(),
             minY = strictBounds.getSouthWest().lat();
    
         if (x < minX) x = minX;
         if (x > maxX) x = maxX;
         if (y < minY) y = minY;
         if (y > maxY) y = maxY;
    
         map.setCenter(new google.maps.LatLng(y, x));
       });
    
       // Limit the zoom level
       google.maps.event.addListener(map, 'zoom_changed', function() {
         if (map.getZoom() < minZoomLevel) map.setZoom(minZoomLevel);
       });
    
       </script> 
    </body> 
    </html>
    

    Screenshot from the above example. The user will not be able to drag further south or far east in this case:

    Google Maps JavaScript API v3 Example: Force stop map dragging

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to limit Google Maps to display only a given country? e.g.
Is it possible to limit export formats only PDF and Excel ?
Possible Duplicate: How to limit number of characters per line in text area to
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Is it possible to implement google style search on SQL server database on tables
there is a limit of 2400 geocoding request for google service. even if each
I have recently started looking into Google Charts API for possible use within the
Is it possible to pull rows from a Google Docs spreadsheet using PHP? In
Is it possible to select from a google app engine db where the key
Is it possible to limit the number of controls in a groupbox in VS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.