Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Make Annotation objects immutable #2546

Closed

Description

@ljbade

In the various annotation objects (Marker etc) we have a number of set... functions. These need to be removed so that they are immutable for the moment.

Main reason is the expected behaviour from developers is that for example Marker.setColor() will change the existing marker's colour. Instead nothing happens.

Full support for mutable annotations is not in the core layer at this stage. Even on iOS you can't update existing markers.

@bleege I think this is good candidate for 2.1.0

Activity

  1. added
    Android
    on Oct 6, 2015
  2. bleege commented on Oct 7, 2015

    @bleege
    Contributor

    @ljbade Sounds good. How about just commenting them out?

  3. added this to the android-v2.1.0 milestone on Oct 7, 2015
  4. ljbade commented on Oct 8, 2015

    @ljbade
    ContributorAuthor

    @bleege I'm not a huge fan of commenting code out. core/iOS seem to avoid commented code but we are getting it scattered in Android.

    I think correct fix here is to make them package private so the MarkerOptions class can still use set.

  5. bleege commented on Oct 8, 2015

    @bleege
    Contributor

    @ljbade Can you help me understand how making them package private so that MarkerOptions can still use them solves this issue? I'm just confused as the original recommendation was "These need to be removed so that they are immutable for the moment."

  6. ljbade commented on Oct 8, 2015

    @ljbade
    ContributorAuthor

    @bleege I mean immutable in the "public API". in #2551 you say we should prefer to use set methods over field access. Package private means MarkerOptions can use them to create the Marker object, but once we return the Marker object to the end developer, they can't make any further changes to the object.

  7. ljbade commented on Oct 8, 2015

    @ljbade
    ContributorAuthor

    @bleege I also noticed that some of the annotation object expose properties from Google Maps API we don't support in core. These should be made private.

  8. ljbade commented on Oct 8, 2015

    @ljbade
    ContributorAuthor

    Fixing up a few other things I noticed:

    • mark Marker, Polygon Polyline as final.
    • mark Annotation, AnnotationOptions, MultiPoint and MultiPointOptions constructors protected.
    • change Circle and CircleOptions to package private as they are currently unimplemented in native layer
    • make Marker, Polygon Polyline constructors package private - only way to create these should be via MapView.
  9. ljbade commented on Oct 8, 2015

    @ljbade
    ContributorAuthor

    Hmm looks like MapView needs to be able to set the ID field on the objects. We might have to implement #2538

  10. 10 remaining items

  11. ljbade commented on Oct 17, 2015

    @ljbade
    ContributorAuthor

    Further work could be to make setId/getId, set/getMapView etc private by directly accessing them in JNI where needed.

    To do this nativeAddMarker could be refactored to take a MarkerOptions and return a Marker.

  12. ljbade commented on Oct 17, 2015

    @ljbade
    ContributorAuthor

    Going to need to remove anchor per #2652 in this 2.2.0 PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Androidrefactor

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions