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 606921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:18:19+00:00 2026-05-13T17:18:19+00:00

Is there a was of automatically setting the zoom level based on the size

  • 0

Is there a was of automatically setting the zoom level based on the size of the country that the map has been centered on?

maps.google.com does exactly what I need, so, for example, if I search for Russia I get a zoom level such that Russia just fits on screen, and when I search for Cuba I get a higher zoom level so that Cuba just fits.

Is there some way of giving the Maps Api a country location and getting an appropriate zoom level.

If not, I guess that I would have to manually (ugh!) create my own table for this information. Or is this information freely available somewhere?

  • 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-13T17:18:19+00:00Added an answer on May 13, 2026 at 5:18 pm

    For API v3 check this answer.

    You can use the Google Maps Client-side Geocoder to get the bounding box of the country, as in the following example:

    // API version 2
    var geocoder = new GClientGeocoder();
    
    geocoder.getLocations("Russia", function (locations) { 
    
        var north = locations.Placemark[0].ExtendedData.LatLonBox.north;
        var south = locations.Placemark[0].ExtendedData.LatLonBox.south;
        var east  = locations.Placemark[0].ExtendedData.LatLonBox.east;
        var west  = locations.Placemark[0].ExtendedData.LatLonBox.west;
    
        var bounds = new GLatLngBounds(new GLatLng(south, west), 
                                       new GLatLng(north, east));
    
        map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
    });
    
    // API version 3
    // ... set north, south, east and west ...
    var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(south, west), 
                                              new google.maps.LatLng(north, east));
    map.fitBounds(bounds);
    

    The screenshots below show the results of the above technique when searching for Russia and Cuba:

    Zoom on Russia and Cuba

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

Sidebar

Related Questions

I noticed that my application was automatically setting all my processes to having been
Is there a setting in ReSharper to automatically format single-statement IF statments with the
I discovered that the toolbars don't automatically wrap in WebKit browswers (Safari, Chrome). There
Is there a setting by which I can get some scripts to load/execute automatically
In Visual Studio 2008 there is a feature that automatically adds a toolbox pane
I am setting up an array that has a transition throughout he colors of
Is there a way to add a custom EAV attribute that automatically gets set
Is there a setting to change where all new classes I create will automatically
In eclipse there is a setting to put an ; automatically at the end
Is there a setting to let the debugger in eclipse automatically pause when a

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.