Cannot see the blue dot and circle at Mylocation Maps

后端 未结 1 1265
天命终不由人
天命终不由人 2021-01-26 17:43

I want google maps to show the location of the user centered at the map as at the image 1 And this is my Fragment Code:

public class MapFragment extends Fragmen         


        
相关标签:
1条回答
  • 2021-01-26 17:52

    Try Code samples of Google.

    The ApiDemos repository on GitHub includes samples that demonstrate the use of location on a map:

    • MyLocationDemoActivity: Using the My Location layer, including runtime permissions
    • LocationSourceDemoActivity: Using a custom LocationSource

    You can use the My Location layer and the My Location button to provide your user with their current position on the map.

    Note: Before enabling the My Location layer, you must ensure that you have the required runtime location permission.

    Enable the My Location layer on the map as follows:

    mMap.setMyLocationEnabled(true);
    

    When the My Location layer is enabled, the My Location button appears in the top right corner of the map. When a user clicks the button, the camera centers the map on the current location of the device, if it is known. The location is indicated on the map by a small blue dot if the device is stationary, or as a chevron if the device is moving.

    You can always check and compare your codes to the sample code to verify or check if your implementation is correct.

    Hope this helps!

    0 讨论(0)
提交回复
热议问题