Vinit ...
Vinit ...

Reputation: 1459

Get latitude longitude when blue dot moves on google maps

I want to get latitude and longitude value when blue dart moves on android google map. Basically, I want to get current location of the phone with high accuracy and immediate update on location change.

But LocationListener not frequently called method onLocationChanged(), that's why I am not getting latest location value.

I tried lot's of other possibilities to get a location with high accuracy and frequently updated value.

I searched and found Fused Location API which is deprecated.

I did not find any website where they solve the issue to get frequent and latest location value.

If I will get blue dart location value then I think my problem will get resolved.

enter image description here

Code:

@Override
public void onMapReady(GoogleMap googleMap) {
    Log.d(TAG, "onMapReady() method called");
    mMap = googleMap;
    mMap.getUiSettings().setZoomControlsEnabled(true);

    if (checkPermission())
        mMap.setMyLocationEnabled(true);
    mMap.setOnMyLocationButtonClickListener(this);
    mMap.setOnMyLocationClickListener(this);

    View locationButton = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).
            getParent()).findViewById(Integer.parseInt("2"));

    RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();

    rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    if (locationGlobal != null) updateMarker(locationGlobal);
}

Upvotes: 0

Views: 641

Answers (1)

RoHiT
RoHiT

Reputation: 372

Try this, it tracks location on map... onLocationChanged(Location location) method called when the location has changed.

Upvotes: 2

Related Questions