Samouray
Samouray

Reputation: 39

How to get the new coordinates of a polygon after editing it?

I just want to know how to get the new coordinates of a polygon after editing it?

I did set the Editable proprety to my polygon to true, and I started changing the bounds of the polygon in the map, and when I finished editing, I want to get the new coordinates to my polygon , so I can store them in a MYSQL Database.

This is the code of my Polygon,

PS: the coordinates of my polygon are retrieved from a MYSQL Database.

cordonnees = [<?php echo $Cordinaates; ?>];
        poly_edit = new google.maps.Polygon({
        paths: cordonnees,
        strokeColor: "#0FF000",
        strokeOpacity: 0.8,
        editable:true,
        strokeWeight: 2,
        fillColor: "#0FF000",
        fillOpacity: 0.35
    });
    poly_edit.setMap(map);

Upvotes: 0

Views: 1948

Answers (2)

Samouray
Samouray

Reputation: 39

Bingo,

I Found it , this is The 2 listeners I Used :

The First Listener :

google.maps.event.addListener(patths, 'set_at', function() {
        new_paths = poly_edit.getPath();
                ...
});

The Second Listener:

google.maps.event.addListener(patths, 'insert_at', function() {
        new_lentgh = patths.getLength();
        new_paths = poly_edit.getPath();
            ...
});

it Works Like a Charm ^^

Upvotes: 0

Chad Killingsworth
Chad Killingsworth

Reputation: 14411

The api reference is your friend: https://developers.google.com/maps/documentation/javascript/reference#Polygon

var currentPaths = poly_edit.getPaths();

Upvotes: 1

Related Questions