Stack Overflow Asked by Orbit on December 4, 2020
We’re displaying a number of map markers on the map representing various objects which are retrieved either from a cache or from an asynchronous network call. When these objects are retrieved, we update the camera to ensure all markers are within view:
LatLngBounds bounds = mBoundsBuilder.build();
mMapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50, 100, 50, 30));
We’re interested in adding the user’s location to the map, and have done so using the LocationComponent
provided by MapBox as shown in this example.
The problem is that when the LocationComponent
has locationComponent .setCameraMode(CameraMode.TRACKING)
set as shown, the camera will focus on the user’s location, without accommodating the markers previously set. Setting the camera mode to CameraMode.NONE
allows the markers to be shown using the code snippet above, however in this case the user’s location will not be accommodated in the mBoundsBuilder
.
The obvious solution seemed to be to listen for location updates and manually add the coordinates to the mBoundsBuilder
so that the user’s location is taken into account. This, however, has a number of problems, such as:
mBoundsBuilder
should only contain a single set of coordinates for the user’s location, the rest of the objects being the previously added markers.getLastKnownLocation
will often return null
.Questions:
Version:
com.mapbox.mapboxsdk:mapbox-android-sdk:6.8.1
Take a look at this -> https://www.github.com/bkhezry/MapDrawingTools it helps in drawing polygons on a map.
Answered by Darsh Reddy on December 4, 2020
1 Asked on December 27, 2021 by shaikh-akbar
3 Asked on December 27, 2021 by viking
2 Asked on December 27, 2021
1 Asked on December 27, 2021
2 Asked on December 27, 2021 by rjoxford
1 Asked on December 27, 2021 by bhavesh-wadhwani
2 Asked on December 27, 2021 by alex-danilov
2 Asked on December 27, 2021 by graham-morby
2 Asked on December 27, 2021 by asknature
2 Asked on December 27, 2021 by dan-pettis
1 Asked on December 27, 2021 by greenie
4 Asked on December 27, 2021 by shino
2 Asked on December 27, 2021 by user12425844
3 Asked on December 27, 2021 by vidalbenjoe
2 Asked on December 27, 2021 by david-jay-brady
2 Asked on December 27, 2021
1 Asked on December 27, 2021 by jack5432109
2 Asked on December 27, 2021
4 Asked on December 27, 2021 by ryandlf
Get help from others!
Recent Questions
Recent Answers
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP