'How to add a drawable image in a map marker
I want to add an image into my map marker, I don't know why this code is not working. The marker is not displaying in my current location. Here is the code.
@Override
public void onLocationChanged(Location location) {
BitmapDescriptor imageDrawable = BitmapDescriptorFactory.fromResource(R.drawable.driver);
if (lastLocation !=null) {
lastLocation = location;
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.addMarker(new MarkerOptions().position(latLng).title("My Location")
.icon(imageDrawable));
mMap.animateCamera(CameraUpdateFactory.zoomTo(10));
}
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|