How to replace blue dot with my icon on google maps v2 in android?

19,346

Solution 1

You will have to stop using GoogleMap.setMyLocationEnabled and write a bit more code, including receiving location updates on your own and adding Circle for accuracy.

Solution 2

I think you pass your current location to LocationSource to be able to use the my-location button.

You have to do that on your own. - set to false gmaps.getUiSettings().setMyLocationButtonEnabled(false);

  • create your own location button
  • if you get your current location, set a marker with your icon on that
  • if you click on your location button, move the camera and center it to the map
Share:
19,346
duggu
Author by

duggu

Top 200 developer in India(Repo wise). Having Android badge

Updated on June 15, 2022

Comments

  • duggu
    duggu almost 2 years

    I am trying to replace blue dot (which shown current location on maps) with my own icon on Google maps v2. I have tried below, none worked.

    Should look like this this

    Below did not work

    Bitmap b = BitmapFactory.decodeResource(getResources(),
            R.drawable.location_arrow1);
    googleMap.addMarker(new MarkerOptions().position(myPosition)
            .title(getIntent().getStringExtra("first_name"))
            .icon(BitmapDescriptorFactory.fromBitmap(b)));
    
  • MaciejGórski
    MaciejGórski almost 11 years
    @Siddharth I think it is more like 10-20 lines for the whole thing ;)
  • Siddharth
    Siddharth almost 11 years
    No, you are kidding, last I counted it was 16. Oh!! you are counting the { }. Bang on man. Btw, still no appreciation from @HemantChandDungriyal.
  • Siddharth
    Siddharth almost 11 years
    No he did not, noone has time to go through 3 links. Instead it would be so much better if you just extract the code from your links and explain what you tried and what happened. Seriously!! how is anyone going to understand what answer in these 3 questions you are referring too. Links are discouraged for this exact reason.
  • Andrew Prock
    Andrew Prock about 9 years
    This answer assumes far too much knowledge of the Google Maps API.
  • Andrew Prock
    Andrew Prock about 9 years
    I dunno, but honestly "write a bit more code" with a link to an API reference left me on my own to find something more practical. Is there a tutorial out there? For my purposes, I wound up using information at: android-developers.blogspot.com/2011/06/…, disabling the dot and using location services to get the location.
  • MaciejGórski
    MaciejGórski about 9 years
    @AndrewProck I've just noticed the link to API that was in my answer is now dead (redirecting to package summary). I've updated answer with a more appropriate link. Thanks for pointing it out.
  • Maveňツ
    Maveňツ about 9 years
    Please quote the most relevant part of the link, in case the target site is unreachable or goes permanently offline.
  • portfoliobuilder
    portfoliobuilder over 7 years
    This does not remove the blue dot, is there more?
  • Ajay2707
    Ajay2707 over 5 years
    As per @leeyang :- In my experience, it worked successfully stackoverflow.com/questions/52007271/…