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

[@capacitor/google-maps] updateRender method in Android does not respect width and height changes #1557

Closed
AE1NS opened this issue Apr 25, 2023 · 4 comments

Comments

@AE1NS
Copy link
Contributor

AE1NS commented Apr 25, 2023

Bug Report

Plugin(s)

@capacitor/google-maps: 4.5.0

Capacitor Version

@capacitor/cli: 4.7.0
@capacitor/core: 4.7.0
@capacitor/ios: 4.7.0
@capacitor/android: 4.7.0

Platform(s)

Android

Current Behavior

When I update the map container dimensions (width, height, x, y) and call 'updateMapBounds', the native map just get repositioned but not resized.

Expected Behavior

The native map should also update its widht and height attributes.

Reproduction

  • Resize the html map wrapper, i.e. set a new height or width, with dev tools on the remote android device
  • Call updateMapBounds on the plugin instance map object or alternatively call window.dispatchEvent(new CustomEvent('resize'))
  • Now the map only updates it x and y values correctly but the size keeps in the initial size.

Other Technical Details

Only the x and y values are updated on the map view in the implementation:

CoroutineScope(Dispatchers.Main).launch {
val mapRect = getScaledRect(delegate.bridge, updatedBounds)
this@CapacitorGoogleMap.mapView.x = mapRect.left
this@CapacitorGoogleMap.mapView.y = mapRect.top
}

@ionitron-bot ionitron-bot bot added the triage label Apr 25, 2023
@ionitron-bot ionitron-bot bot removed the triage label Apr 25, 2023
@AE1NS AE1NS changed the title [@capacitor/google-maps] updateRender method in Android does not respect width and height [@capacitor/google-maps] updateRender method in Android does not respect width and height changes Apr 25, 2023
@AE1NS
Copy link
Contributor Author

AE1NS commented Apr 28, 2023

Replacing it with this, works:

CoroutineScope(Dispatchers.Main).launch {
        val bridge = delegate.bridge
        val layoutParams =
                FrameLayout.LayoutParams(
                        getScaledPixels(bridge, config.width),
                        getScaledPixels(bridge, config.height),
                )
        layoutParams.leftMargin = getScaledPixels(bridge, config.x)
        layoutParams.topMargin = getScaledPixels(bridge, config.y)
        [email protected] = layoutParams
}

But I dont know if it has any side effects.

@AE1NS
Copy link
Contributor Author

AE1NS commented May 3, 2023

Or this:

CoroutineScope(Dispatchers.Main).launch {
        val mapRect = getScaledRect(delegate.bridge, updatedBounds)
        [email protected] = mapRect.left
        [email protected] = mapRect.top
        [email protected] = getScaledPixels(delegate.bridge, config.width)
        [email protected] = getScaledPixels(delegate.bridge, config.height)
        [email protected]()
}

@AE1NS
Copy link
Contributor Author

AE1NS commented May 17, 2023

Closed in favor of #1594

@AE1NS AE1NS closed this as completed May 17, 2023
@ionitron-bot
Copy link

ionitron-bot bot commented Jun 16, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants