Smithey93
Smithey93

Reputation: 45

Google Maps v3 API - Drawing Circles on Map

What I'm trying to do is draw a circle on google maps and retrieve the latitude/longitude/radius to store in a database, alternatively a geometry object would also be fine.

Using the standard code from https://developers.google.com/maps/documentation/javascript/examples/drawing-tools i created the map and drawing toolbox. What i can't seem to do is get the lat/long/radius from the map using javascript, surely this must be possible.

Any ideas?

Thanks

Note - my code is identical to the google example, i figured it was better to link to it rather than copying ~60+ lines of html into a post.

Thanks

Upvotes: 0

Views: 1377

Answers (1)

Synthetx
Synthetx

Reputation: 609

Ref: https://developers.google.com/maps/documentation/javascript/drawing

google.maps.event.addListener(drawingManager, 'circlecomplete', function(circle) {
      var radius = circle.getRadius(),
      center = circle.getCenter();
});

Edit: getCenter()

Upvotes: 2

Related Questions