Get Drawn Data from Google Maps
Clash Royale CLAN TAG#URR8PPP
Get Drawn Data from Google Maps
I'm using the Google Maps JavaScript API. I've added a DrawingManager
, and can draw custom shapes over the base map. How do I access the shape data that I drew?
DrawingManager
The DrawingManager
doesn't seem to have any data getters, and my Map
's data
property appears empty even when a drawing is present:
DrawingManager
Map
data
map.data.toGeoJson(e => console.log(e))
>>> Object type: "FeatureCollection", features:
Related question: google maps API - “toGeoJson” returns object with geometry null
– geocodezip
41 mins ago
Related question: GMap Drawing tools to image jpeg (static map URL)
– geocodezip
41 mins ago
Thanks @geocodezip! I notice that both of those answers "access" the data by either copying it or manually storing references to it. Would you say that this is the best approach, and that there's no way to access the drawn geometry directly?
– Xavier Holt
21 mins ago
The DrawingManager doesn't provide access to the drawn objects, other than in the "complete" event listeners (or at least didn't last I looked, that might change, but I'm not expecting it to)
– geocodezip
10 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Would the downvoter care to explain? I'm happy to add more details if the question isn't clear enough.
– Xavier Holt
2 hours ago