You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
I am a student who's doing his best to use MapBox Android SDK !
I'm using MapBox to display a LOT of markers on a map (which is already kind of an issue since I can't find any tutorial on how to do marker clustering with MapBox Android SDK... but that's not my main issue for now, if someone could explain how to do marker clustering with MapBox Android SDK though, it'd be awesome)
The markers must have a definite colour (out of 4 available), and they must be differently oriented (rotation in degrees of the displayed marker).
What I'm currently doing
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(final MapboxMap mapboxMap) {
//Cleaning the map if it had anything on it before
mapboxMap.removeAnnotations();
//Creating a list of markers
List<MarkerOptions> markers = new ArrayList<>();
//Creating my Icon from a drawable ressource
Icon yellowIcon = IconFactory.getInstance(context).fromDrawable(ContextCompat.getDrawable(context, R.drawable.yellow_marker));
//Filling up the list
for (int i = 0; i < numberOfMarkers; i++){
markers.add(new MarkerOptions()
.position(lat,lng)
.title("blabla")
.snippet("blabla too")
.icon(yellowIcon)
)
}
//Adding all the markers to the map
mapboxMap.addMarkers(markers);
}
});
Problems I have with what I'm doing
There's no way to rotate the marker the way I'd like to. MarkerViews have a "rotate" option, but there's no way of adding points like I did, dynamically from a List, by calling "add" once only (and not as many times as there are markers).
I did try to create a rotated bitmap of the ressource I need before creating an Icon out of it and using it for the markers, but when I do so :
I run into an OutOfMemory exception (something like "failed to allocate") if I run that piece of code multiple times.
The markers appear once, and if I refresh them they're not displayed anymore (I don't really know why) even though they still seem to be created since I still run into the OOM exception caused by the rotated bitmap creations. NOTE: this problem doesn't appear when I don't put any icon, or when I put a custom one, it really just appears when I try to rotate a bitmap beforehand, to use as an Icon
Questions
Is there any way to rotate a marker icon that is a MarkerOption and not a MarkerView (so I can still use addMarkers to add them all at once) ? Something that doesn't imply having 360 icons for each degree of rotation, multiplicated by the four icon colors I need.
Is is possible to cluster the markers with what I'm doing to add my markers on the map with Mapbox 4.2.0beta, and if yes, how could I do so (I really can't find any tutorial that properly explains how with mapbox)
Thank you so much for your time, I'm sorry if it was a lot to read, and I hope someone out there will find solutions to my issues ! I'll answer as fast as possible to any kind of question.
Benjisora
The text was updated successfully, but these errors were encountered:
Platform: Android
Mapbox SDK version: 4.2.0beta
Explained issue
I am a student who's doing his best to use MapBox Android SDK !
I'm using MapBox to display a LOT of markers on a map (which is already kind of an issue since I can't find any tutorial on how to do marker clustering with MapBox Android SDK... but that's not my main issue for now, if someone could explain how to do marker clustering with MapBox Android SDK though, it'd be awesome)
The markers must have a definite colour (out of 4 available), and they must be differently oriented (rotation in degrees of the displayed marker).
What I'm currently doing
Problems I have with what I'm doing
There's no way to rotate the marker the way I'd like to. MarkerViews have a "rotate" option, but there's no way of adding points like I did, dynamically from a List, by calling "add" once only (and not as many times as there are markers).
I did try to create a rotated bitmap of the ressource I need before creating an Icon out of it and using it for the markers, but when I do so :
Questions
Thank you so much for your time, I'm sorry if it was a lot to read, and I hope someone out there will find solutions to my issues ! I'll answer as fast as possible to any kind of question.
Benjisora
The text was updated successfully, but these errors were encountered: