Closed lomza closed 5 years ago
Hey @lomza, thanks for reaching out!
You will need to convert your SVG to a bitmap (you can easily find how to do that on the web) and add it to the map with
mapboxMap.getStyle(new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
style.addImage("my_image", bitmap);
}
});
then you can reference that image's ID in the SymbolOptions
SymbolOptions symbolOptions = new SymbolOptions()
.withLatLng(new LatLng(6.687337, 0.381457))
.withIconImage("my_image")
...
@LukasPaczos , thank you so much! It worked perfectly ;)
Hi @LukasPaczos i want to add multiple markers on it, and I add in onStyleLoaded
// create symbol manager GeoJsonOptions geoJsonOptions = new GeoJsonOptions().withTolerance(0.4f); symbolManager = new SymbolManager(mapView, mapboxMap, style, null, geoJsonOptions); // create a symbol SymbolOptions symbolOptions = new SymbolOptions() .withLatLng(new LatLng(31.995560, 34.767070)) .withIconImage("Charge") .withIconSize(1.3f) .withDraggable(true); symbol = symbolManager.create(symbolOptions);
But it isn't showing any markers, may I ask what may be the problems? do you have any multiple markers' example?
Sure @gracedotdotdot, check out PressForSymbolActivity
example.
when I try to use the addSymbol function in your reference. I add the
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v8:0.7.0'
line in my build.gradle, but it comes error
Duplicate class com.mapbox.mapboxsdk.plugins.annotation.Annotation found in modules classes.jar (com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.6.0) and classes.jar (com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v8:0.7.0)
May I ask what should I delete?
You can inspect your dependencies and verify where the duplicate is coming from: https://stackoverflow.com/a/39020703/9126211.
Hi I've already deleted the duplicate libraries but it's still popping duplicate class error. may I ask why can't I use the code in #1017 to add multiple markers dynamically? Thank you
Thanks @LukasPaczos for helping out. I was finding difficulty to implement custom icons to the map that goes with our algorithm. It worked like a charm.
Hi,
I've been following example of SymbolActivity.java - https://github.com/mapbox/mapbox-plugins-android/blob/master/app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/SymbolActivity.java and found out that Maki images as used as symbol image. I have an svg image, imported as vector image into Android Studio. How can I use it for my symbol icon image?
Thanks!