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

The Archive Base Latest Questions

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

I need to plot a set of coordinates on the map in response to

  • 0

I need to plot a set of coordinates on the map in response to a user selection, and when it happens, I’d like to pan the map to focus on that set of points. How can I find the smallest bounding box (LatLngBounds) that contains all of the coordinates?

  • 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-16T02:20:48+00:00Added an answer on May 16, 2026 at 2:20 am

    In addition to the Stack Overflow post which @Crescent Fresh pointed to above (which is using the v2 API), the method you’d want to use is the LatLngBounds.extend().

    Here’s a complete example, using the v3 API:

    <!DOCTYPE html>
    <html> 
    <head> 
       <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
       <title>Google Maps LatLngBounds.extend() Demo</title> 
       <script src="http://maps.google.com/maps/api/js?sensor=false" 
               type="text/javascript"></script> 
    </head> 
    <body> 
       <div id="map" style="width: 400px; height: 300px;"></div> 
    
       <script type="text/javascript"> 
    
       var map = new google.maps.Map(document.getElementById('map'), { 
         mapTypeId: google.maps.MapTypeId.TERRAIN
       });
    
       var markerBounds = new google.maps.LatLngBounds();
    
       var randomPoint, i;
    
       for (i = 0; i < 10; i++) {
         // Generate 10 random points within North East America
         randomPoint = new google.maps.LatLng( 39.00 + (Math.random() - 0.5) * 20, 
                                              -77.00 + (Math.random() - 0.5) * 20);
    
         // Draw a marker for each random point
         new google.maps.Marker({
           position: randomPoint, 
           map: map
         });
    
         // Extend markerBounds with each random point.
         markerBounds.extend(randomPoint);
       }
    
       // At the end markerBounds will be the smallest bounding box to contain
       // our 10 random points
    
       // Finally we can call the Map.fitBounds() method to set the map to fit
       // our markerBounds
       map.fitBounds(markerBounds);
    
       </script> 
    </body> 
    </html>
    

    Screenshot:

    Google Maps LatLngBounds.extend() Demo

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

Sidebar

Related Questions

I need to make a plot that functions like a density plot for high-density
Can DirectX be used to plot a set of points on a WPF control
I need plot a curve for my data , the source is like :
I'm having data as like below. I need to plot graph based on region.
I need to get a plot that fits the data automatically using matplotlib. This
I'm not that smart like some of you geniuses. I need some help from
I need help programatically graphing more points than can fit in a single Excel
I have a set of (x,y) coordinates that describe the trajectory of an object.
i need to set background color of hosting view in core plot to clear
I'm putting together my first plot with ggplot2. I need to set a shape

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.