capacitor-community / capacitor-community/google-maps
feat(shapes): add support for drawing polyline, polygon and circle
- Dominant language
- Java
- Stars
- 161
- Forks
- 65
- PR merge metrics
- No merged PRs in 30d
Description
It should be possible to draw basic shapes on the map. There's actually already an open PR that adds this: https://github.com/capacitor-community/google-maps/pull/149
It adds the methods `addPolygon`, `addPolyline` and `addCircle` with some options. E.g. to fill them with a solid color and to adjust the color of the stroke (i.e. the border of the shape).
However, to be on par with the API the Google SDK offers, some additional functionality is needed as well.
---
We will first focus on completing the functionality of the `polygon` shape only. Later on, we will add similar functionality to the `polyline` and `circle` shapes as well. This way we keep the scope smaller. The requirements are as follows:
---
The API in the PR regarding the `polygon` (as said above) only has the `addPolygon` method right now. But it should be on par with the API that the Android SDK of Google itself offers (can be found [here](https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Polygon)).
More specifically, this will thus entail the following changes:
- [ ] 1. Keep a list of drawn polygons. This means a polygon that is added, should be saved in some sort together with an guid. For reference: the `addMarker` method has similar functionality.
- [ ] 2. The `PolygonOptions` of the PR already supports specifying the `points`, `tag`, `strokeColor`, `fillColor`, `strokeWidth`, `zIndex` and the `visibility`. Support should also be added for `clickable`, `geodesic`, `holes`, `strokePattern`, `strokeJointType`.
- [ ] 3. Add a `getPolygon(id: string)` method, that returns all properties of the specified polygon. For reference: the `getḾap` method has similar functionality.
- [ ] 4. Add a `updatePolygon(id: string, preferences: object)` method, which accepts the same preference parameters as the `addMarker` method, so the polygon can be updated.
- [ ] 5. Add a `removePolygon(id: string)` method, so a polygon can be removed (remember to update the list mentioned in 1 as well).
Bonus 1: it should be possible to - instead of a solid color fill - apply a pattern of images to a polygon. For more information, check this [Stack Overflow question](https://stackoverflow.com/questions/52268761/fill-polygon-with-icons)
Bonus 2: it should be possible to place the shapes _on top_ of the markers. Normally they are drawn behind the markers.
Contributor guide
Assessment
This issue has not been assessed yet.