Anarion
Anarion

Reputation: 2534

Selecting a Google map polygon via jQuery selector

Is there a way to select a Google maps API polygon via jQuery selector? Something like

$('.polygon')

I want to be able to send polygon.getpath() array to server when user presses "save" button.

Or should it be done via

google.maps.event.addListener()

If so, how can I pass my savePolygon(polygon) function to this listener?

EDIT:

I currently have

 google.maps.event.addListener(drawingManager, 'polygoncomplete', function(polygon) {
     google.maps.event.addDomListener($('#save-btn')[0], 'click', savePolygon);
 }

and I want to pass the polygon to savePolygon function.

Upvotes: 0

Views: 300

Answers (2)

Anarion
Anarion

Reputation: 2534

What I really needed was

 google.maps.event.addDomListener($('#save-btn')[0], 'click', function (){savePolygon(polygon)});

Upvotes: 0

Mir Shakeel Hussain
Mir Shakeel Hussain

Reputation: 517

google.maps.event.addListener(poligonn, 'click', function(event) { 
    var totalPath = this.getPath();
    savePolygon(totalPath);
});

use this piece of code this may help

Upvotes: 1

Related Questions