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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:05:11+00:00 2026-05-14T07:05:11+00:00

To draw a circle on map I have a center GLatLng (A) and a

  • 0

To draw a circle on map I have a center GLatLng (A) and a radius (r) in meters.

Here’s a diagram:

           -----------
        --/           \--
      -/                 \-
     /                     \
    /                       \
   /                   r     \
   |            *-------------*
   \             A           / B
    \                       /
     \                     /
      -\                 /-
        --\           /--
           -----------

How to calculate the GLatLng at position B? Assuming that r is parallel to the equator.

Getting the radius when A and B is given is trivial using the GLatLng.distanceFrom() method – but doing it the other way around not so. Seems that I need to do some heavier math.

  • 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-14T07:05:11+00:00Added an answer on May 14, 2026 at 7:05 am

    We will need a method that returns the destination point when given a bearing and the distance travelled from a source point. Luckily, there is a very good JavaScript implementation by Chris Veness at Calculate distance, bearing and more between Latitude/Longitude points.

    The following has been adapted to work with the google.maps.LatLng class:

    Number.prototype.toRad = function() {
       return this * Math.PI / 180;
    }
    
    Number.prototype.toDeg = function() {
       return this * 180 / Math.PI;
    }
    
    google.maps.LatLng.prototype.destinationPoint = function(brng, dist) {
       dist = dist / 6371;  
       brng = brng.toRad();  
    
       var lat1 = this.lat().toRad(), lon1 = this.lng().toRad();
    
       var lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + 
                            Math.cos(lat1) * Math.sin(dist) * Math.cos(brng));
    
       var lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(dist) *
                                    Math.cos(lat1), 
                                    Math.cos(dist) - Math.sin(lat1) *
                                    Math.sin(lat2));
    
       if (isNaN(lat2) || isNaN(lon2)) return null;
    
       return new google.maps.LatLng(lat2.toDeg(), lon2.toDeg());
    }
    

    You would simply use it as follows:

    var pointA = new google.maps.LatLng(25.48, -71.26); 
    var radiusInKm = 10;
    
    var pointB = pointA.destinationPoint(90, radiusInKm);
    

    Here is a complete example using Google Maps API v3:

    <!DOCTYPE html>
    <html> 
    <head> 
       <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
       <title>Google Maps Geometry</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"> 
          Number.prototype.toRad = function() {
             return this * Math.PI / 180;
          }
    
          Number.prototype.toDeg = function() {
             return this * 180 / Math.PI;
          }
    
          google.maps.LatLng.prototype.destinationPoint = function(brng, dist) {
             dist = dist / 6371;  
             brng = brng.toRad();  
    
             var lat1 = this.lat().toRad(), lon1 = this.lng().toRad();
    
             var lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + 
                                  Math.cos(lat1) * Math.sin(dist) * Math.cos(brng));
    
             var lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(dist) *
                                          Math.cos(lat1), 
                                          Math.cos(dist) - Math.sin(lat1) *
                                          Math.sin(lat2));
    
             if (isNaN(lat2) || isNaN(lon2)) return null;
    
             return new google.maps.LatLng(lat2.toDeg(), lon2.toDeg());
          }
    
          var pointA = new google.maps.LatLng(40.70, -74.00);   // Circle center
          var radius = 10;                                      // 10km
    
          var mapOpt = { 
             mapTypeId: google.maps.MapTypeId.TERRAIN,
             center: pointA,
             zoom: 10
          };
    
          var map = new google.maps.Map(document.getElementById("map"), mapOpt);
    
          // Draw the circle
          new google.maps.Circle({
             center: pointA,
             radius: radius * 1000,       // Convert to meters
             fillColor: '#FF0000',
             fillOpacity: 0.2,
             map: map
          });
    
          // Show marker at circle center
          new google.maps.Marker({
             position: pointA,
             map: map
          });
    
          // Show marker at destination point
          new google.maps.Marker({
             position: pointA.destinationPoint(90, radius),
             map: map
          });
       </script> 
    </body> 
    </html>
    

    Screenshot:

    Google Maps Geometry

    UPDATE:

    In reply to Paul’s comment below, this is what happens when the circle wraps around one of the poles.

    Plotting pointA near the north pole, with a radius of 1,000km:

      var pointA = new google.maps.LatLng(85, 0);   // Close to north pole
      var radius = 1000;                            // 1000km
    

    Screenshot for pointA.destinationPoint(90, radius):

    Close to north pole

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

Sidebar

Related Questions

how to draw a circle in openlayer map? i have tried in diff way,
I am drawing the circle on map with specifying the radius and it'll draw
I have to draw a circle in live wallpaper when it touches the boundary
I'm trying to draw a circle using OpenCV and OpenGL, I have to do
I'm trying to draw a circle with radius X kilometers, but it occurred to
I'm trying to draw a circle in the center of the screen of my
In the documentation for Leaflet here: http://leafletjs.com/reference-1.2.0.html#circlemarker it says that CircleMaker extends Circle, and
I'm working on an iPhone app that shows a map with multiple circle overlays
I have been able to draw an ellipse on my map using latitude and
I have a map custom view that inherit from MKOverlayPathView. I need this custom

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.