capacitor-community / google-maps

Capacitor Plugin using native Google Maps SDK for Android and iOS.

Home Page:https://capacitor-community.github.io/google-maps/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

tafelnl opened this issue · comments

commented

It should be possible to draw basic shapes on the map. There's actually already an open PR that adds this: #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.

commented

@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 :)

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

Missing polyline prevent us from using the capacitor google map.

Any idea when Circle will be added?

Any idea when Circle will be added?

Was this feature ever added??

commented

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

Hi,

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

=

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?

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 @asma-omar i was able to use polyline feature on the map
i had to edit the google map source code

result

Screenshot_20230509150816

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

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.

commented

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.

commented

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

Thank you so much.

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

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

Thank you :-)

commented

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

This is amazing.
Thank you so much.

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