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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:11:04+00:00 2026-06-12T15:11:04+00:00

Using Google maps API V3, specifically using the drawing tools (only the rectangle is

  • 0

Using Google maps API V3, specifically using the drawing tools (only the rectangle is enabled) as seen here:

https://developers.google.com/maps/documentation/javascript/overlays#drawing_tools

But I have the following question,

  1. Can I (if so how), by action of the user clicking a link on the same page, retrieve the lat,lng of the top left corner of the polygon and the bottom right, and send to a url, ie;

http://foo.bar/script.php?latoftopleft=17.4479216&longoftopleft=78.37720100000001&latofbotright=17.443172404867163&longofbotright=78.39395944192506

  • 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-12T15:11:05+00:00Added an answer on June 12, 2026 at 3:11 pm

    Retrieving the Rectangle

    One way to retrieve the rectangle drawn by the user is to use Drawing Events:

    var rectangle;
    google.maps.event.addListener(drawingManager, 'rectanglecomplete', function(newRect) {
        rectangle = newRect;
    });
    

    Whenever a rectangle is drawn by the user, it will assign the Rectangle overlay object to the rectangle global variable.

    Extracting information about the Rectangle

    The google.maps.Rectangle class has a getBounds() method, which returns a LatLngBounds object. You can use the getNorthEast() and getSouthWest() methods to deduce the top-left and bottom-right corner coordinates.

    You can bind an onclick event to the link. The click event handler might look something like this:

    function clickEventHandler(event) {
        // check if the rectangle has been assigned
        if (rectangle == undefined) {
            alert('No rectangles have been drawn yet!');
            return;
        }
    
        // obtain the bounds and corner coordinates of the rectangle
        var rectangleBounds = rectangle.getBounds();
        var northEast = rectangleBounds.getNorthEast();
        var southWest = rectangleBounds.getSouthWest();
    
        // deduce the top-left and bottom-right corner coordinates
        var topLeft = new google.maps.LatLng(northEast.lat(), southWest.lng());
        var bottomRight = new google.maps.LatLng(southWest.lat(), northEast.lng());
    
        // Now that you have the coordinates, all you have to do is use an AJAX
        // technique of your choice to send the HTTP request to script.php.
        // ...
    }
    

    Further reading:

    • How do I bind a click to an anchor without a framework (javascript)
    • Pure Javascript send post data without a form
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Google maps JavaScript API. Here is code : <!DOCTYPE html PUBLIC
I am using Google Maps API for reverse lookup of an address, specifically Country,
I am developing web-application using Google Maps API and ASP.NET Ajax. Here is my
I'm using Google Maps API V3 with Twitter Bootstrap and here's what I got.
I am using Google Maps API V2 (I know, but i am editing a
I'm using Google Maps' API and added a few markers in a map. Each
I just started working using Google Maps API yesterday, and trying to set up
I am using Google Maps API V3 to create a marker and the Infobox
All the examples I've come across using Google Maps API seem to show a
I have created an infobox using google maps api v3 and infoBox from the

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.