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

Update show coordinates sample #152

Merged
merged 13 commits into from
Dec 18, 2023

Conversation

prupani-7
Copy link

Description

PR to update the sample to use composable mapview from the toolkit
Versions.gradle file from PR uses "arcgisToolkitVersion = '200.3.0-1'"

So, update new module script PR should be merged before this PR

Links and Data

Sample Epic: runtime/kotlin/issues/3368

What To Review

  • Review updated files

How to Test

Run the sample on the sample viewer or the repo.

@prupani-7 prupani-7 changed the base branch from main to feature-branch/geo-compose December 13, 2023 21:36
Copy link
Collaborator

@hud10837 hud10837 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prupani-7 Looks good and works as expected, a couple small comments

import com.esri.arcgismaps.sample.showcoordinatesinmultipleformats.components.MapViewModel

/**
* Main screen layout for the sample app
*/
@Composable
fun MainScreen(sampleName: String) {
fun MainScreen(sampleName: String, application: Application) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be passed in? Could you use LocalContext.current.applicationContext?

val arcGISMap = ArcGISMap(Basemap(basemapLayer))
// the collection of graphics overlays used by the MapView
val graphicsOverlayCollection = rememberGraphicsOverlayCollection()
// the collection of graphics overlays used by the MapView
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a duplicate comment to line 55


Scaffold(
topBar = { SampleTopAppBar(title = sampleName) },
content = {
content = { it ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intentional? I expect it to be named or not declared explicitly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it, thanks!

@prupani-7
Copy link
Author

@hud10837 thanks for the feedback! addressed them, re-review?

Copy link
Collaborator

@hud10837 hud10837 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@shubham7109 shubham7109 added the enhancement New feature or request label Dec 18, 2023
@shubham7109 shubham7109 self-requested a review December 18, 2023 21:10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The graphic point does not update when I try the reverse workflow.

  • Tapping a point elsewhere
  • Pasting in a predeterminate coordinate
  • All text fields update to the new coordinate as expected
  • The graphic point on map does not

Could you debug to see if this issue is due to the toolkit MapView or the sample workflow?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed...
the geometry of the coordinateLocationGraphic was not getting updated to the new Point.

Copy link
Collaborator

@shubham7109 shubham7109 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes @prupani-7. Few comments to address..

Comment on lines 88 to 90
graphicsOverlays = graphicsOverlayCollection.apply {
this.add(graphicsOverlay)
},
Copy link
Collaborator

@shubham7109 shubham7109 Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think simple assignment properties here would be more clear, and we can move the apply block away from the Compose call and add it to the line the val is declared.

    // graphics overlay for the MapView to draw the graphics
    val graphicsOverlay = remember { GraphicsOverlay() }
    // the collection of graphics overlays used by the MapView
    val graphicsOverlayCollection = rememberGraphicsOverlayCollection().apply {
        add(graphicsOverlay)
    }
Suggested change
graphicsOverlays = graphicsOverlayCollection.apply {
this.add(graphicsOverlay)
},
graphicsOverlays = graphicsOverlayCollection,

Copy link
Author

@prupani-7 prupani-7 Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution fixed the issue with showMessageDialog not showing and app crashing with error (GO object already owned)
I think everytime MapView composable was called, we were adding the same GO object to the GO collection, without clearing it.
but moving the apply block in declaration fixes this. Thanks!

Comment on lines 92 to 94
/**
* Updates the tapped graphic and coordinate notations using the [tappedPoint]
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Updates the tapped graphic and coordinate notations using the [tappedPoint]
*/
// retrieve the map point on MapView tapped

// set up a graphic to indicate where the coordinates relate to, with an initial location
val initialPoint = Point(0.0, 0.0, SpatialReference.wgs84())

val coordinateLocation = Graphic(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coordinateLocation might be confused with an actual location point.

Could rename it to coordinateLocationGraphic

Suggested change
val coordinateLocation = Graphic(
val coordinateLocationGraphic = Graphic(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app crashes when I type in an incorrect coordinate point. Ideally, it should display the messageDialogVM.showMessageDialog

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above comment..

@prupani-7
Copy link
Author

@shubham7109 thanks for the feedback, applied your suggestions, please re-review?

Copy link
Collaborator

@shubham7109 shubham7109 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for applying the changes 👍

@prupani-7 prupani-7 merged commit cd958b4 into feature-branch/geo-compose Dec 18, 2023
1 check passed
@prupani-7 prupani-7 deleted the priy/updateShowCoordinatesSample branch December 18, 2023 23:35
@shubham7109 shubham7109 changed the title Priy/update show coordinates sample Update show coordinates sample Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants