[go: nahoru, domu]

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

Adding support for KmlLayer without relying on MapEffect #447

Open
br00 opened this issue Oct 27, 2023 · 2 comments
Open

Adding support for KmlLayer without relying on MapEffect #447

br00 opened this issue Oct 27, 2023 · 2 comments
Labels
triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@br00
Copy link
br00 commented Oct 27, 2023

As developer I would like to be able to add different layers (Kml, GeoJson, etc) to the GoogleMap composable.

A KmlLayer needs a GoogleMap instance to be built. KmlLayer(GoogleMap map, int resourceId, Context context)
At the moment the only way to add a Kml layer is using the experimental MapEffect (which it may get removed in the future).

Loading a KmlLayer is also slow so it needs to be done in a background thread.

Considering all of the above I came up with a solution but it would be nice to have a different way to do it.
This solution will not work anymore if MapEffect is removed.

val scope = rememberCoroutineScope()
val context = LocalContext.current
val aKmlLayer: KmlLayer? = null
GoogleMap(
    ...
) {
    MapEffect { gMap ->
        scope.launch {
            withContext(Dispatchers.IO) {
                aKmlLayer = KmlLayer(gMap, R.raw.kml_file, context)
                withContext(Dispatchers.Main) {
                    aKmlLayer?.addLayerToMap()
                }
            }
        }
    }
}
@br00 br00 added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Oct 27, 2023
@wangela
Copy link
Member
wangela commented Oct 27, 2023

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.

@br00 Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

@AwaisKhan128
Copy link

There is another issue of using MapEffect. It blocks the onClick functionality of polygon, polyline and circles. Anyone has any solution? @br00 man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. 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