Skip to content
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

[Feature request]: Marker IDs are forcibly overwritten regardless of user-specified IDs #288

Open
1 task done
yutsuki3 opened this issue Feb 25, 2025 · 2 comments
Open
1 task done
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@yutsuki3
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Use case

Description

There is an issue in the current implementation where user-specified marker IDs are ignored and new IDs are forcibly generated internally. This makes it difficult to manage, update, or delete individual markers.

Current Behavior

In common_view_api.dart, _createMarkerId() always generates a new ID, overwriting any ID that may have been set in MarkerOptionsDto:

final List<MarkerDto> markersToAdd = options
.map((MarkerOptionsDto options) =>
MarkerDto(markerId: createMarkerId(), options: options))
.toList();

Proposal

The implementation should prioritize user-specified IDs and only auto-generate IDs when none are provided:

final List<MarkerDto> markersToAdd = options
.map((MarkerOptionsDto options) =>
MarkerDto(
markerId: options.markerId ?? createMarkerId(),
options: options
))
.toList();
  • Preserves user-specified marker IDs
  • Enables easier management of individual markers
  • Allows reliable updating and deletion of existing markers
@yutsuki3 yutsuki3 added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Feb 25, 2025
@jokerttu jokerttu added status: investigating The issue is under investigation, which is determined to be non-trivial. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Feb 27, 2025
@jokerttu
Copy link
Contributor

jokerttu commented Feb 28, 2025

Note that marker IDs are not regenerated when the updateMarkers method is used to update existing markers that were created using the addMarkers method.

Also MarkerOptions (nor MarkerOptionsDto) do not have field for MarkerId.

@jokerttu
Copy link
Contributor

@yutsuki3
Thanks for your feature request!

The reason we don't allow developers to set IDs manually is to avoid collisions, as having the same ID on multiple markers causes issues in the platform implementation.

When a marker is added, the platform returns the added markers in the same order with generated IDs.
If developers need custom IDs, they currently have to handle mapping between IDs in their own implementation. This means they need to maintain a separate mapping between their custom IDs and the generated platform IDs, ensuring that interactions such as marker clicks or updates can be correctly linked back to their original identifiers. I admit this is not the easiest approach, as it requires additional logic to track and synchronize these mappings manually.

We will discuss internally whether we should provide the possibility to customize marker IDs (or other object IDs), with a clear warning about potential collisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants