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
Author by
duggu
Top 200 developer in India(Repo wise). Having Android badge
Updated on June 15, 2022Comments
-
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.
- Android Maps API v2 Change MyLocation Icon
- Maps V2 myLocation blue dot callback
- Disable center button in MyLocation at Google Map API V2
Should look like 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 almost 11 years@Siddharth I think it is more like 10-20 lines for the whole thing ;)
-
Siddharth almost 11 yearsNo, you are kidding, last I counted it was 16. Oh!! you are counting the { }. Bang on man. Btw, still no appreciation from @HemantChandDungriyal.
-
Siddharth almost 11 yearsNo 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 about 9 yearsThis answer assumes far too much knowledge of the Google Maps API.
-
Andrew Prock about 9 yearsI 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 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ňツ about 9 yearsPlease quote the most relevant part of the link, in case the target site is unreachable or goes permanently offline.
-
portfoliobuilder over 7 yearsThis does not remove the blue dot, is there more?
-
Ajay2707 over 5 yearsAs per @leeyang :- In my experience, it worked successfully stackoverflow.com/questions/52007271/…