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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:25:51+00:00 2026-05-29T10:25:51+00:00

I am a bit of a beginner at google maps api. I managed to

  • 0

I am a bit of a beginner at google maps api. I managed to let the user to draw a polygon on the map and then I want to get the coordinates on the drew polygon.

I have used the following segment of code but it gave me the following error Uncaught TypeError: Object [object Object] has no method ‘getPath’

this is the code that I used

function startShape() {


    initialize();
    document.getElementById('lat').disabled = true;
    document.getElementById('lng').disabled = true;
  var polygon = new GPolygon([],"ff0000", 2, 0.7,"ff0000",0.2);
  startDrawing(polygon, "Shape " + (++shapeCounter_), function() {
    var cell = this;
    var area = polygon.getArea();
    cell.innerHTML = (Math.round(area / 10000) / 100) + "km<sup>2</sup>";
  });
  showcoor(polygon);
}




function startDrawing(poly, name, onUpdate) {

 map.addOverlay(poly);
  poly.enableDrawing(options);
  poly.enableEditing({onEvent: "mouseover"});
  poly.disableEditing({onEvent: "mouseout"});
  GEvent.addListener(poly, "endline", function() {
    //var cells = addFeatureEntry(name, color);
    //GEvent.bind(poly, "lineupdated", cells.desc, onUpdate);
    GEvent.addListener(poly, "click", function(latlng, index) {
      if (typeof index == "number") {
        poly.deleteVertex(index);
      } 
    });
  });


}


function showcoor (poly) {
GEvent.addListener(poly, "endline", function() {
    GEvent.addListener(poly, "click", function() {
    var str;
               var vertices = this.getPath();
              for (var i =0; i < vertices.length; i++) {
                var xy = vertices.getAt(i);
                str += xy.lat() +"," + xy.lng()+"<br />";
              }
              alert (str);
            });
            });
    }
  • 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-29T10:25:52+00:00Added an answer on May 29, 2026 at 10:25 am

    There is no getPath method on the GPolygon object. See the GPolygon reference.

    Instead, you’ll need to use getVertexCount() and getVertex(i).

    for (var i = 0, I = this.getVertexCount(); i < I; ++i) {
      var xy = this.getVertex(i);
      str += xy.lat() + ', ' + xy.lng() + '<br />';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Bit of a beginner question here: Say I have a block of xml: <root>
So I've been getting into a bit of assembly lately and I'm a beginner
I'm a beginner at C, and using Turbo C++ compiler (16 bit). In the
Bit confused here, I have an on-demand instance but do I get charged even
I am a bit of a beginner when it comes to Vim and it
I am a bit of a GlassFish beginner, so please forgive my ingnorance on
Im a bit of a beginner when it comes to javascript constructs. Im trying
this is a bit of a beginner's question, but I've searched everywhere and can't
I am a beginner of Android and i need a bit hints and help.
I'm a bit of a beginner, and I'm using :before for paragraph numbers. I

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.