Search code examples
androidgoogle-maps-api-2android-gpscurrentlocation

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);

Solution

  • 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);