简体   繁体   中英

Mapbox for android: when I import markerview dependancy, my original mapbox map code stops working

I have been using Mapbox tutorials and etc., to write a code that creates a map and and finds user's location. For this purpose i have been using these dependencies:

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.0.1' implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.5.0'

What I wanted to do next was to write a code when I could add markers, for this reason I have imported the dependency shown below:

implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0'

I have noticed that once I do this the method addLocationListener() is not found anymore, and getLastLocation methods are also not working and seems they require some parameters now which was not necessary before. I wonder if anyone had similar problem and could advice how to solve this. Thanks!

I'd use the latest Maps SDK version 9.2.0 https://docs.mapbox.com/android/maps/overview/

The Location Layer Plugin is deprecated: https://docs.mapbox.com/android/plugins/overview/location-layer/

I'd use the LocationComponent instead. It's a part of the Maps SDK: https://docs.mapbox.com/android/maps/overview/location-component and https://docs.mapbox.com/android/maps/examples/#device-location

The MarkerView is still useable, but it'll have some performance issues because it uses Android-system View s. Instead, consider using the Maps SDK SymbolLayer https://docs.mapbox.com/android/maps/overview/data-driven-styling/#symbol or the Annotation Plugin https://docs.mapbox.com/android/plugins/overview/annotation/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM