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

feat: update 'samples/overlay-hideshow' to account for tilt (v=beta) #929

Open
dudiw opened this issue Oct 24, 2021 · 7 comments
Open

feat: update 'samples/overlay-hideshow' to account for tilt (v=beta) #929

dudiw opened this issue Oct 24, 2021 · 7 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@dudiw
Copy link

dudiw commented Oct 24, 2021

I noticed that the google.maps.OverlayView in 'overlay-hideshow' sample gets distorted when the map is tilted (beta feature).

See example (hold shift and drag with the mouse to tilt and rotate the map)
https://jsfiddle.net/jq5f0zsk/1/

The issue becomes apparent when the tilt > 0
image

Is there a way to configure the OverlayView to remain "flat"?
Alternatively, perhaps the 'div' can be transformed (3d rotation) to compensate for the tilt and rotation of the camera?

Thank you!

@dudiw dudiw 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 24, 2021
@jpoehnelt
Copy link
Contributor

jpoehnelt commented Oct 25, 2021

Alternatively, perhaps the 'div' can be transformed (3d rotation) to compensate for the tilt and rotation of the camera?

This is probably the fix. I'll see about updating the sample to account for this.

https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d()

@jpoehnelt jpoehnelt added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed triage me I really want to be triaged. labels Oct 25, 2021
@dudiw
Copy link
Author

dudiw commented Oct 25, 2021

@jpoehnelt Awesome!
It's a bit tricky since the tilt and heading of google.maps.Map are in the camera's reference frame, whereas the div rotation(3d) is in the image's reference frame.

Thank you for looking into this!

@jpoehnelt
Copy link
Contributor

No guarantees. It's been way too long since I took linear algebra and graphics courses!

@jpoehnelt
Copy link
Contributor

Some of the utils in deckgl might be useful?? https://github.com/visgl/deck.gl/blob/master/modules/google-maps/src/utils.js

@dudiw
Copy link
Author

dudiw commented Oct 26, 2021

Thank you @jpoehnelt for the effort!

I also found this old overlay-tiler repo that demonstrates how to transform an overlay (including planar rotation).
From overlay.js line 156:

var proj = this.getProjection(); // google.maps.Map.getProjection()

/* properties topLeft, topRight, bottomRight initialized in setInitialGCP_() line 110 */
var tl = proj.fromLatLngToDivPixel(this.get('topLeft'));
var tr = proj.fromLatLngToDivPixel(this.get('topRight'));
var br = proj.fromLatLngToDivPixel(this.get('bottomRight'));
img.style.transform =  'matrix(' + [tr.x - tl.x, tr.y - tl.y, br.x - tr.x, br.y - tr.y, tl.x, tl.y] + ')';

Regarding deckgl utils.js, the method getViewPropsFromCoordinateTransformer (line 174) might contain some hints on GoogleMaps projection matrix.

Not sure if this helps - I'll keep searching

@jpoehnelt jpoehnelt removed their assignment Jun 17, 2022
@regeter
Copy link
Contributor

regeter commented Jun 25, 2022

This can be served well by using Deck.gl with Bitmap Layer:
https://jsfiddle.net/regeter/j0fuqzpc/90/

@dudiw
Copy link
Author

dudiw commented Jun 25, 2022

This can be served well by using Deck.gl with Bitmap Layer: https://jsfiddle.net/regeter/j0fuqzpc/90/

Excellent @regeter ! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. 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