openmobilehub / omh-maps

omh-maps
Apache License 2.0
8 stars 1 forks source link

Insufficient Context for Code Snippet Placement #66

Closed dzuluaga closed 1 year ago

dzuluaga commented 1 year ago

Issue 1:

The getting started documentation lacks clear guidance on where to include the provided code snippet. This omission can confuse developers who are unfamiliar with the proper placement of the code within their project.

Suggested Solution: Please add more context to the documentation, explicitly stating that the code snippet should be enclosed within a Fragment class. Additionally, provide a sample implementation of a Fragment class that includes the necessary interfaces and overrides.

Example Fix:

class MapFragment : Fragment(), OmhOnMapReadyCallback {

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        // Here's where you should include the code snippet
        // Obtain the OmhMapFragment and get notified when the map is ready to be used.
        val omhMapFragment = childFragmentManager.findFragmentById(R.id.fragment_map_container) as? OmhMapFragment
        omhMapFragment.getMapAsync(this)
    }

    override fun onMapReady(omhMap: OmhMap) {
        // Now you can use the omhMap object!
    }

}

Issue 2:

Title: Missing Implementation of OmhOnMapReadyCallback

Description: The getting started documentation fails to mention that the Fragment class must implement the OmhOnMapReadyCallback interface. This interface is necessary to receive the callback when the map is ready to be used.

Suggested Solution: It would be helpful to add a note in the documentation emphasizing that the Fragment class needs to implement the OmhOnMapReadyCallback interface. This ensures that developers understand the required implementation to receive the map-ready callback.

Issue 3:

Title: Compilation Error in omhFragment.getMapAsync

Description: The code snippet provided in the getting started documentation includes omhFragment.getMapAsync(this), which leads to a compilation error due to the absence of a non-null assertion (!!) or safe call. This issue can prevent developers from correctly implementing the map-related functionality.

Suggested Solution: To resolve the compilation error, please update the code snippet in the documentation. Recommend using a non-null assertion (!!) or, preferably, a safe call (?.) to ensure successful compilation.

Example Fix:

val omhMapFragment = childFragmentManager.findFragmentById(R.id.fragment_map_container) as? OmhMapFragment
omhMapFragment?.getMapAsync(this)
hans-hamel commented 1 year ago

Added but the Readme using directly in the Activity to simplify the explanation as Google does, see doc

dzuluaga commented 1 year ago

Please replace activity for the fragment to be included in the code-starter branch.

hans-hamel commented 1 year ago

Sure in the code-starter branch can use fragment to hold the map

hans-hamel commented 1 year ago

The starter-code branch in the maps-starter-sample uses a fragment