Conversation
dkhawk
marked this pull request as ready for review
September 22, 2026 17:11
dkhawk
added this pull request to stack #73
September 22, 2026 17:12
dkhawk
force-pushed
the
feat/projection3d-and-surface-click
branch
from
September 23, 2026 18:38
1404b45 to
df139cb
Compare
…tle to strings.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🥞 Stacked PR (2 of 2)
chore(format): apply spotless ktlint formatting to maps3d-compose and maps3d-compose-demo)chore/spotless-formatting-compose-and-demo(will be retargeted tomainonce chore(format): apply spotless ktlint formatting to maps3d-compose and maps3d-compose-demo #71 merges)Resolves #21
Summary
Introduces a rudimentary 3D perspective projection utility (
Projection3D) and interactive sample activities across Jetpack Compose, Kotlin Views, and Java Views demonstrating how to project 3D spatial coordinates (LatLngAltitude) into 2D viewport screen pixels (PointF/Offset/Point) to anchor custom 2D UI overlays over 3D world geometry.Also notes that full 3D surface and building click detection requested in #21 is already natively supported in the SDK via
GoogleMap3D.setMap3DClickListener.All Android Lint review feedback (hardcoded preview strings, text size >= 11sp, and localized string resources) has been addressed, and complete 3-way language parity is maintained.
Key Changes
1. Mathematical Projection Engine (
Projection3D.kt)Added in both
Maps3DSamples/ApiDemos/commonandmaps3d-compose:LatLngAltitudeinto local tangent coordinates.range,heading,tilt,roll).@JvmOverloads constructorfor seamless Java invocation.toScreenCoordinate(point): Returns aScreenCoordinatewith(x, y)pixels, line-of-sightdepth(meters), and view frustum visibility state (isVisible).toScreenLocation(point)/toScreenLocationF(point)/toScreenOffset(point): Returns integerPoint, floatingPointF, or ComposeOffset(ornullif behind camera plane).fromScreenLocation(screenX, screenY, targetAltitude): Raycasts from the camera eye through screen pixeltargetAltitude.2. Math Unit Tests (
Projection3DTest.kt)Added in
Maps3DSamples/ApiDemos/common/src/test:cameraCenter_projectsToExactScreenCenter: Validates camera center projects exactly to viewport center(width / 2, height / 2).pointBehindCamera_isMarkedNotVisible: Verifies points behind the camera eye are culled (isVisible = false, negative depth).cardinalDirections_projectToCorrectScreenQuadrants: Tests cardinal direction offsets project to expected quadrants.fromScreenLocation_centerPixel_recoversCameraCenter: Verifies inverse unprojection recovery.roundTrip_projectAndUnproject_matchesOriginalGroundCoordinates: Verifies round-trip coordinate accuracy.3. Jetpack Compose Sample (
Projection3DActivity.kt)Added to
maps3d-compose-demo:onCameraChanged.BoxWithConstraintsto feed dynamicmaxWidthandmaxHeightintoProjection3D.onMapClickto re-project tapped coordinates.4. Kotlin Views Sample (
Projection3DActivity.kt)Added to
Maps3DSamples/ApiDemos/kotlin-app:SampleBaseActivityand inflatescontrol_panel_projection_3d.xml.CardViewover 3D world geometry by dynamically updatingtranslationXandtranslationYon camera change ticks.flyCameraTo.5. Java Views Sample (
Projection3DActivity.java)Added to
Maps3DSamples/ApiDemos/java-app:SampleBaseActivity.googleMap3D.setCameraChangedListenerandsetMap3DClickListener.MainActivity.javaand manifest; updatedMainActivityTestto 23 samples.Verification
./gradlew :Maps3DSamples:ApiDemos:common:testDebugUnitTest --tests "com.example.maps3d.common.Projection3DTest"-> 5/5 passed./gradlew :maps3d-compose:spotlessCheck :maps3d-compose-demo:spotlessCheck-> BUILD SUCCESSFUL./gradlew :Maps3DSamples:ApiDemos:java-app:lintDebug :Maps3DSamples:ApiDemos:kotlin-app:lintDebug-> BUILD SUCCESSFUL (0 errors)./gradlew :Maps3DSamples:ApiDemos:java-app:compileDebugJavaWithJavac :Maps3DSamples:ApiDemos:kotlin-app:compileDebugKotlin :Maps3DSamples:ApiDemos:common:compileDebugKotlin-> BUILD SUCCESSFUL