-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for polygoncomplete event in Drawing Manager #148
Comments
It looks like this would entail saving the resulting Polygon to the array of maps objects and then returning its Guid index. This would allow interacting with drawing manager polygons like they were created manually. |
I will take a look on sunday. |
It is not that simple. Polygon is like proxy for js object and dont have ANY properties. In this case it return polygon with it properties, so deserialise to polygon it is impossible since first it dont existist in _blazorGoogleMapsObjects and second Polygon object dont have any propertys, so it would need other object.
|
For this library maybe it would make sense have PolygonDto with properties in such case, but then having MyPolygon wont have abilities to have add path or change properties on map. |
I think you could create protected constructor, then create custom js even where it set object to _blazorGoogleMapsObjects and returns id (guid), then create JsObjectRef and pass it to new Polygon class via custom factory method and then to constructor. |
Thanks for looking at this! I may PR if I have the time, possibly this week, otherwise if you are able to add this it would be much appreciated! |
Looking more closely at what you said above, I think we're on the same page. The Polygon object is a proxy, like you said, and you need to call into JS to get any of its properties. Since the polygoncomplete event returns a polygon, you could save that to the _blazorGoogleMapsObjects list and then return a Polygon from the event. Easy enough in theory. I'd need to study the JS further to be more confident. |
No. You dont need to return polygon. You need to add and return id. Then create polygon with that in via Polygon constructor on C# side with that Id (JsObjectRef ). Just looks how polygon is created via private constructor. I think issue here how call c# from js side. Not sure if same event pattern will work |
By return I mean the event would return polygon on the C# side. I realize that the event would just return the ID on the JS side. |
You're a legend! |
Currently, the only supported event for the DrawingManager is overlaycomplete.
I am proposing that polygoncomplete support be added to DrawingManager:
https://developers.google.com/maps/documentation/javascript/reference/drawing#DrawingManager.polygoncomplete
This would be useful as it would allow users to directly manipulate the Polygon instead of only getting the lat/lng list. I think support is mostly there, only there is no public constructor for Polygon:
BlazorGoogleMaps/GoogleMapsComponents/Maps/Polygon.cs
Line 33 in fcd5a45
This leads to this error when using the polygoncomplete event:
![image](https://user-images.githubusercontent.com/26885142/133682786-f8ae4b52-77c8-44a3-b2c5-a97bee2cbbfc.png)
The text was updated successfully, but these errors were encountered: