Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display current location blue point without setMyLocationEnabled true?

I am using google map V2 and i need to display custom image button click to get current location with blue point and no display to setMyLocationEnabled button. And already false this method but current location is display but blue point is not display.

enter image description here

  googleMap.setMyLocationEnabled(false);
like image 359
Najib.Nj Avatar asked Nov 27 '17 09:11

Najib.Nj


People also ask

How accurate is the blue dot on Google Maps?

In other words, the app did pinpoint you on the map, but the location might not be 100 percent accurate. More often than not, your current location should be someone within the light blue circle, so give Google Maps a few more seconds until it manages to refresh and precisely determine where you are.

Why is Google not showing accurate location?

More ways to improve location accuracyReload your browser (such as Chrome, Firefox, or Safari). Check to make sure you have a strong internet connection. Double-check your browser's permission settings using the instructions above. Restart your computer.


1 Answers

Well i guess you have your current latitude and longitude using the gps. After that it is really simple. You make a marker object and add it to the map like this.

MarkerOptions yourMakerOptions;
Marker yourMarker;


    yourMakerOptions = new MarkerOptions();
    yourMakerOptions.title("Title");
    yourMakerOptions.snippet("");
    yourMarkerOptions.position(new LatLng(currentLatitude,currentLongitude));
    //Set your marker icon using this method.
    yourMakerOptions.icon();

Finally add it to the map.

yourMarker = map.addMarker(yourMakerOptions);

To move the map to the current location call this method in onClickListener of your button.

map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(currentLatitude, currentLongitude), 14));

Hope this helps.

Try this :

map.setMyLocationEnabled(true);
map.getUiSettings().setMyLocationButtonEnabled(false);
like image 115
Sarthak Gandhi Avatar answered Nov 15 '22 05:11

Sarthak Gandhi