I was wondering how one could use his own icons in a Flutter-Mapbox plugins' marker?
There's no default marker icon (no provided icon - no marker), and there's not enough documentation on how to use a custom image.
adding a symbol (marker) is as follows:
mapController.addSymbol(
SymbolOptions(
geometry:LatLng(0.0, 0.0), // location is 0.0 on purpose for this example
iconImage: "pin"
)
);
whereas the IconImage
, a String, is the field which should contain the data about the icon (obviously), but the given example repository doesn't clarify the needed parameters (url, path etc.).
Providing a path to the assets doesn't work (unlike other widgets). In the example, they provide the IconImage field the value airport-15
, and when running the app, it actually works, but I can't seem to find the resources' location (it's not in @drawables or my assets folder, or any other place in the project)
You have to create a custom style on using MapBox Studio
.
customize basic template
my_sym
and add newly created datasourcemy_sym
two times. (first one will close the option menu & second one will open a new menu with symbol propertiesicon
tab & select new icon. You can also upload your own svg icon.styleString
property.For more info follow steps here https://docs.mapbox.com/help/tutorials/add-points-pt-1/
API reference: https://docs.mapbox.com/mapbox-gl-js/api/