I really need some advice on this.
Im trying to get the Mapbox Annotation Plugin to work. on https://docs.mapbox.com/android/plugins/overview/annotation/ it says to create a SymbolManager like this:
// create symbol manager object
val symbolManager = SymbolManager(mapView, mapboxMap)
On "SymbolManager" im getting the error: None of the following functions can be called with the arguments supplied.
- (MapView, MapboxMap, Style) defined in com.mapbox.mapboxsdk.plugins.annotation.SymbolManager
- (MapView, MapboxMap, Style, CoreElementProvider, String?, GeoJsonOptions?, DraggableAnnotationController!) defined in com.mapbox.mapboxsdk.plugins.annotation.SymbolManager
- (MapView, MapboxMap, Style, String?) defined in com.mapbox.mapboxsdk.plugins.annotation.SymbolManager
- (MapView, MapboxMap, Style, String?, GeoJsonOptions?) defined in com.mapbox.mapboxsdk.plugins.annotation.SymbolManager
It seems as if i need a style object. So i deciced to go like this :
override fun onMapReady(mapboxMap: MapboxMap) {
this.map = mapboxMap
mapboxMap.setStyle(Style.MAPBOX_STREETS) {
//this here is just to be able to see your own location on the android device, it should not interfer with the symbol manager (i guess)
enableLocationComponent(it)
//get the current Stly (MAPBOX_STREETS)
val style: Style = mapboxMap.style!!
//Create Symbol Manager, it requires a style object so i'm using the one i created above, documentation actually doenst say any style object is needed here
val symbolManager = SymbolManager(CellMap!!, mapboxMap, style)
//non data driven properties
symbolManager.iconAllowOverlap = true
//create symbol to test the symbol function
val symbolOptions: SymbolOptions = SymbolOptions()
.withLatLng( LatLng(37.410, -122.084))
.withIconImage("res/mipmap/ic_launcher/ic_launcher.png")
.withIconSize(1.3f)
.withSymbolSortKey(10.0f)
.withDraggable(true)
symbol = symbolManager.create(symbolOptions)
}
}
I'm using an icon that was already given by android studio. Still it's not showing any symbol on the map when i open it, and i don't understand why. The code i am using i got from the java code here: https://github.com/mapbox/mapbox-plugins-android/blob/master/app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/SymbolActivity.java I just had to 'convert' it to kotlin, which i did myself. Not sure if i did anything wrong with it, but at least im not getting any errors.
Thanks in advance. I hope i provided every piece of information required to assist me. If not i would be very happy to provide it. Also i tried to format everything the correct way, sorry if i missed something.