Can`t add a custom icon on Marker
Hello,
I'm trying to add a custom Icon to my markers in my app. Before it was made like this way:
marker.setMarker(getResources().getDrawable(R.drawable.ic_marker_no_premium));
Now, according with the documentation, in order to add a Marker I have to do it with MarkerOptions, and do the following:
SpriteFactory spriteFactory = mv.getSpriteFactory();
Drawable drawable = ContextCompat.getDrawable(this, R.mipmap.ic_directions_boat_black_18dp);
Sprite icon = spriteFactory.fromDrawable(drawable);
The thing is that I'm not able to make this work. First of all SpriteFactory library is not recognized in mapbox 3.2.0 version, and I can't find any other function that allow me to pursue this.
Is this an external library that I need to add?
Would you please give me any guidance on how to do this?
Regards
Hi,
You should now use IconFactory. Sth like this should do the job.
IconFactory iconFactory = IconFactory.getInstance(context);
Icon icon = iconFactory.fromResource(R.id.your_img_res_id);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.icon(icon);
@andreinass Thank you for reaching out and reporting your problem, The explanation from @mpuchala is correct. More information about this change can be found in https://github.com/mapbox/mapbox-gl-native/issues/3304.
Since nothing actionable is left to do, closing.