Konstantin Konopko
Konstantin Konopko

Reputation: 5418

Stop using location with Google Map fragment

I use GM fragment in my activity. And I use checkbox to show or hide that map fragment. I want deactivate GoogleMap when it is hidden to disable using GPS. But I cant do that in my activity until it is closed. Any suggestions?

mapGoogle = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_google)).getMap();

Upvotes: 2

Views: 1417

Answers (1)

Osvald Ivarsson
Osvald Ivarsson

Reputation: 1243

You can use setMyLocationEnabled(boolean enabled) to enable or disable the GPS in GoogleMap.

Run

mapGoogle.setMyLocationEnabled(false);

when you want to disable the GPS, and then

mapGoogle.setMyLocationEnabled(true);

when you want to enable it again.

Upvotes: 2

Related Questions