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

  • SEARCH
  • Home
  • 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 811813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:06:11+00:00 2026-05-15T01:06:11+00:00

I am new to google maps api. I’d like suggestions on achieving the following

  • 0

I am new to google maps api. I’d like suggestions on achieving the following functionality: whenever the page loads, the map will load centered around the US. Imagine a box around the US with given lat/longs specifying the minimum and maximum boundaries. I need the map to load at the appropriate zoom (and zoom needs to be disabled) such that this box composes the entire map.

Basically, I’m wondering if there is a function that loads the map based on lat/long boundaries (or some way to acheive this), rather then loading the map given a zoom level.

  • 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-15T01:06:12+00:00Added an answer on May 15, 2026 at 1:06 am

    Assuming you are using the v3 API, you may want to use the fitBounds method as follows:

    <!DOCTYPE html>
    <html> 
    <head> 
       <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
       <title>Google Maps fitBounds</title> 
       <script src="http://maps.google.com/maps/api/js?sensor=false" 
               type="text/javascript"></script> 
    </head> 
    <body> 
       <div id="map" style="width: 500px; height: 350px;"></div> 
    
       <script type="text/javascript"> 
          var myOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
          var map = new google.maps.Map(document.getElementById("map"), myOptions);
          var geocoder = new google.maps.Geocoder();
    
          geocoder.geocode({'address': 'US'}, function (results, status) {
             var ne = results[0].geometry.viewport.getNorthEast();
             var sw = results[0].geometry.viewport.getSouthWest();
    
             map.fitBounds(results[0].geometry.viewport);               
          }); 
       </script> 
    </body> 
    </html>
    

    Screenshot:

    Google Maps fitBounds

    In the above example, I’m getting the viewport of the US by geocoding. However, you could also create a LatLngBounds object yourself by passing the North East and South West points, and the fitBounds method will zoom and pan your map such that it will fit on the map canvas.

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

Sidebar

Related Questions

I am creating a map using the new(ish) v3 of the Google Maps API
Google has this fine new Google Maps API v3 which is a Javascript API.
I'm using the new Google Maps API v3 . It works great with Firefox/Chromo/Safari
Instead of Google Maps API's default info window, I'm going to use other jQuery
GOOGLE MAPS API V3 is what i'm trying to use. I have all the
I am using Google Maps API (v3) to draw a few maps on a
I'm using the Google maps API (v2) to display a country overlay over a
I am using Google maps JavaScript API. Here is code : <!DOCTYPE html PUBLIC
I am having problems with the google maps API V3. It seems that every
I'm switching from v2 to v3 google maps api and got a problem with

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.