C00kieMonsta
C00kieMonsta

Reputation: 338

Is there a way to add a custom icon to map's Mapbox?

I might have skipped some documentation about flutter_map plugin, but I could not find any way to use a simple .png image as a custom icon for a Mapbox marker?

Should I maybe use another plugin? Or is there a way to do what I attempted to do?

Upvotes: 3

Views: 1398

Answers (1)

m0nac0
m0nac0

Reputation: 56

You can do that with the mapbox_gl plugin by calling

MapboxMapController.addSymbol(
  SymbolOptions(
    geometry: LatLng(latitude, longitude),
    iconImage: iconImage,
  );

You can use the name of one of your asset images as iconImage or the name of one of the icons included in your style (e.g. 'defaultMarker' should be included in every style).
There is also an example of this in the place_symbol.dart file of the plugin's example project.

Upvotes: 3

Related Questions