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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:49:44+00:00 2026-06-08T09:49:44+00:00

I have a map that is taller than wide. I noticed that in some

  • 0

I have a map that is taller than wide. I noticed that in some instances, the fitBounds method was failing to adjust the zoom and center correctly in order to display all of the markers.

I’ve managed to isolate the issue in this example:

http://jsbin.com/welcome/2568

In the example I first try to load 23 positions and you will notice its zoomed quite far in. What I’m doing is:

//extending 23 positions doesn't really work
bounds = new google.maps.LatLngBounds ();
for (var i = 0; i < markerList.length; i++) {
    pos = new google.maps.LatLng (markerList[i]["Za"],markerList[i]["$a"])
    bounds.extend(pos);
}
window.map.fitBounds(bounds);

After 5 seconds I run that basic script again, but this time instead of extending 23, I only extend the bounds 5 times. This time the map actually zooms out!

What I noticed is that to get this issue to reproduce, I have to set the width and height of the canvas div:

<div id="map_canvas" style="width:450px;height:600px;"></div>

So I guess my question is: How can I both set the map canvas size and successfully fitBounds() for 25+ positions?

  • 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-06-08T09:49:46+00:00Added an answer on June 8, 2026 at 9:49 am

    I just figured what was happening is that I was setting the minZoom in the map configuration.

    It seems that if the minZoom is lower than the one needed by fitBounds() to display all the positions, it silently fails.

    The reason the width of the map influenced is that the thinner the map, the more it had to zoom out to display the whole set of positions, and when it met the constraint of minZoom, it would die.

    The reason the subset of 5 positions would work I think is just because it wasn’t reaching the minZoom.

    To solve the issue I removed the minZoom setting.

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

Sidebar

Related Questions

I have a 2d map that the user can zoom and pan using the
I have a world map that is 800px wide and 340px high. How can
I have one Map that contains some names and numbers Map<String,Integer> abc = new
I have a map that is frequently read but rarely write to. Some operations
So I have a Map that has some values in it being passed into
I have a map that i want to update from a separate thread. Im
I have image map that can I move, but this map will be so
I have a map that represents a DB object. I want to get 'well
I have a Map that uses a Set for the key type, like this:
I have a map that reads an XML file; it's all very simple and

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.