Search code examples
androidandroid-mapviewandroid-overlay

Showing a custom marker on user his position


I am using Google Maps v2 Android MapView. The marker of the position of the user is a blue circle. I want to change this to my drawable.

Is this possible?

I know I can add markers like this but this doesn't apply to the user his own position:

this.marker = BitmapDescriptorFactory.fromResource(R.drawable.marker);
this.map.addMarker(new MarkerOptions().position(position).title(name)
                .draggable(false).icon(this.marker));

Solution

  • Yes you can add your custom marker to show user current location....but you need to calculate the latitude and longitude your self using locationListener and show that location on map as follows:

    public void setCurretnLocMarker(loc) {
    
            LatLng mLatLng=new LatLng(loc.getLatitude(), loc.getLongitude());
            getMap().animateCamera(CameraUpdateFactory.newLatLng(mLatLng));
    
            getMap().addMarker(new MarkerOptions().position(mLatLng).title(mLatLng.toString()).draggable(false));
        }