google-maps icon indicating copy to clipboard operation
google-maps copied to clipboard

feat(shapes): add support for drawing polyline, polygon and circle

Open tafelnl opened this issue 4 years ago • 20 comments

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).

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

Bonus 2: it should be possible to place the shapes on top of the markers. Normally they are drawn behind the markers.

tafelnl avatar Mar 31 '22 10:03 tafelnl

@galilov will soon start with the implementation on Android. If someone would like to contribute and help with the iOS part, please feel free to chime in :)

tafelnl avatar Mar 31 '22 10:03 tafelnl

Any ideas when polygons will be added. I just upgraded my project from cordova to capacitor.....and now realize with the feature missing, I am going to have to revert everything back.....

nodiced922 avatar Oct 25 '22 00:10 nodiced922

Missing polyline prevent us from using the capacitor google map.

woodely avatar Nov 07 '22 22:11 woodely

Any idea when Circle will be added?

IbrahimElkhatib avatar Nov 09 '22 17:11 IbrahimElkhatib

Any idea when Circle will be added?

Was this feature ever added??

EdByrnee avatar Jan 16 '23 01:01 EdByrnee

Partly shipped in 2.0.0-beta.6: adding polygons is now supported.

tafelnl avatar Jan 20 '23 15:01 tafelnl

Hi,

Is there a timeline for adding Polylines to this Plugin? It works wonderfully in my app BTW.

WynOwen72 avatar Apr 21 '23 11:04 WynOwen72

=

Hi,

Is there a timeline for adding Polylines to this Plugin? It works wonderfully in my app BTW.

did you mean polyline works on your app ?how can i add polyline to map?

asma-omar avatar Apr 27 '23 11:04 asma-omar

Hi Good Morning,

What I meant is that the basic map, zoom, maptype etc all work. My question is your second question:

how can i add polyline to map?

I see it's not officially part of the plugin but I've seen bits referring to polylines in the code.

WynOwen72 avatar May 01 '23 09:05 WynOwen72

@WynOwen72 @asma-omar i was able to use polyline feature on the map i had to edit the google map source code

result

Screenshot_20230509150816

Timileyin105 avatar May 09 '23 14:05 Timileyin105

if the team hasn't gotten this feature already developed, i can take my time to contribute to this

Timileyin105 avatar May 09 '23 14:05 Timileyin105

if the team hasn't gotten this feature already developed, i can take my time to contribute to this

My skills are weak in Java and Swift but i'd love to take a peek.

WynOwen72 avatar May 09 '23 22:05 WynOwen72

PRs are welcome! Please try to adhere to the coding guidelines and principles in the codebase. That'll make it easier for me to review it.

tafelnl avatar May 10 '23 05:05 tafelnl

alright

Timileyin105 avatar May 10 '23 06:05 Timileyin105

Hello @Timileyin105 and @tafelnl. Some news about Polylines?

Thank you so much.

jldlxs avatar May 11 '23 21:05 jldlxs

@jidlxs and @WynOwen72 i plan to work on this and push it tomorrow

Timileyin105 avatar May 12 '23 11:05 Timileyin105

@jidlxs and @WynOwen72 i plan to work on this and push it tomorrow

Thank you :-)

WynOwen72 avatar May 12 '23 11:05 WynOwen72

@jidlxs and @WynOwen72 i plan to work on this and push it tomorrow

This is amazing. Thank you so much.

jldlxs avatar May 12 '23 16:05 jldlxs

hello @jldlxs @WynOwen72 @tafelnl i just opened a pull for the polyline currently i use window and can't use xcode to work on the feature for ios

@tafelnl please review this and let me know if ok or there is still some works thanks

Timileyin105 avatar May 13 '23 16:05 Timileyin105