Open zhichaoZhang opened 4 months ago
I encountered the same problem, is there a solution?
@bytebitx @zhichaoZhang please provide sample project reproducing the issue.
class MapBoxViewActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_map_box)
with(findViewById<MapView>(R.id.mapView)) {
// 设置地图样式
mapboxMap.loadStyle(Style.SATELLITE)
location.locationPuck = createDefault2DPuck(true)
location.enabled = true
location.puckBearing = PuckBearing.COURSE
viewport.transitionTo(
targetState = viewport.makeFollowPuckViewportState(
FollowPuckViewportStateOptions.Builder()
.zoom(12.0)
.pitch(0.0)
.build()
),
transition = viewport.makeImmediateViewportTransition()
)
}
}
}
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">
<com.mapbox.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
@bytebitx @zhichaoZhang please provide sample project reproducing the issue.
Obtain the user location according to the documentation guidelines. https://docs.mapbox.com/android/maps/guides/user-location/device-location/
val locationService : LocationService = LocationServiceFactory.getOrCreate()
var locationProvider: DeviceLocationProvider? = null
val request = LocationProviderRequest.Builder()
.interval(IntervalSettings.Builder().interval(0L).minimumInterval(0L).maximumInterval(0L).build())
.displacement(0F)
.accuracy(AccuracyLevel.HIGHEST)
.build();
val result = locationService.getDeviceLocationProvider(request)
if (result.isValue) {
locationProvider = result.value!!
} else {
Log.error("Failed to get device location provider")
}
val locationObserver = object: LocationObserver {
override fun onLocationUpdateReceived(locations: MutableList<Location>) {
Log.e(TAG, "Location update received: " + locations)
}
}
locationProvider.addLocationObserver(locationObserver)
Is there any way to obtain my running log so that you can check the cause of the problem?
Environment
Observed behavior and steps to reproduce
Run the Mapbox Maps Android project and enter the user location display page, but the current location cannot be displayed.
The log is as follows:
17:32:35.358 28395-28395 Mapbox I [common]: Using Mapbox Common SDK v24.5.0(edbe9cbfd) 17:32:35.402 28395-28395 Mapbox I [maps-core]: Using Mapbox Core Maps SDK v11.5.1(47046e34d8) 17:32:35.416 28395-28418 Mapbox I [MapboxReachability]: Application permission for ACCESS_NETWORK_STATE granted 17:32:35.723 28395-28435 Mapbox I [LifecycleUtils]: Task: TaskInfo{userId=0 taskId=901 displayId=0 isRunning=true baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.mapbox.maps.testapp/.ExampleOverviewActivity } baseActivity=ComponentInfo{com.mapbox.maps.testapp/com.mapbox.maps.testapp.ExampleOverviewActivity} topActivity=ComponentInfo{com.mapbox.maps.testapp/com.mapbox.maps.testapp.ExampleOverviewActivity} origActivity=null realActivity=ComponentInfo{com.mapbox.maps.testapp/com.mapbox.maps.testapp.ExampleOverviewActivity} numActivities=1 lastActiveTime=75089755 supportsMultiWindow=true resizeMode=1 isResizeable=true minWidth=-1 minHeight=-1 defaultMinSize=220 token=WCT{android.window.IWindowContainerToken$Stub$Proxy@9825e12} topActivityType=1 pictureInPictureParams=null shouldDockBigOverlays=false launchIntoPipHostTaskId=-1 lastParentTaskIdBeforePip=-1 displayCutoutSafeInsets=Rect(0, 136 - 0, 0) topActivityInfo=ActivityInfo{917b9e3 com.mapbox.maps.testapp.ExampleOverviewActivity} launchCookies=[android.os.BinderProxy@24f7fe0] positionInParent=Point(0, 0) parentTaskId=-1 isFocused=true isVisible=true isVisibleRequested=true isSleeping=false topActivityInSizeCompat=false topActivityEligibleForLetterboxEducation= false topActivityLetterboxed= false isFromDoubleTap= false topActivityLetterboxVerticalPosition= -1 topActivityLetterboxHorizontalPosition= -1 topActivityLetterboxWidth=-1 topActivityLetterboxHeight=-1 locusId=null displayAreaFeatureId=1 cameraCompatControlState=hidden} 17:32:35.800 28395-28435 Mapbox I [LifecycleUtils]: Task: TaskInfo{userId=0 taskId=901 displayId=0 isRunning=true baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.mapbox.maps.testapp/.ExampleOverviewActivity } baseActivity=ComponentInfo{com.mapbox.maps.testapp/com.mapbox.maps.testapp.ExampleOverviewActivity} topActivity=ComponentInfo{com.mapbox.maps.testapp/com.mapbox.maps.testapp.ExampleOverviewActivity} origActivity=null realActivity=ComponentInfo{com.mapbox.maps.testapp/com.mapbox.maps.testapp.ExampleOverviewActivity} numActivities=1 lastActiveTime=75089755 supportsMultiWindow=true resizeMode=1 isResizeable=true minWidth=-1 minHeight=-1 defaultMinSize=220 token=WCT{android.window.IWindowContainerToken$Stub$Proxy@b4098d4} topActivityType=1 pictureInPictureParams=null shouldDockBigOverlays=false launchIntoPipHostTaskId=-1 lastParentTaskIdBeforePip=-1 displayCutoutSafeInsets=Rect(0, 136 - 0, 0) topActivityInfo=ActivityInfo{109da7d com.mapbox.maps.testapp.ExampleOverviewActivity} launchCookies=[android.os.BinderProxy@24f7fe0] positionInParent=Point(0, 0) parentTaskId=-1 isFocused=true isVisible=true isVisibleRequested=true isSleeping=false topActivityInSizeCompat=false topActivityEligibleForLetterboxEducation= false topActivityLetterboxed= false isFromDoubleTap= false topActivityLetterboxVerticalPosition= -1 topActivityLetterboxHorizontalPosition= -1 topActivityLetterboxWidth=-1 topActivityLetterboxHeight=-1 locusId=null displayAreaFeatureId=1 cameraCompatControlState=hidden} 17:32:58.405 28395-28420 Mapbox I [metrics]: Metrics collection period: 0s 17:32:58.491 28395-28419 Mapbox I [metrics]: Metrics collection period: 0s 17:32:58.498 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: renderThreadPrepared=false and Android surface is not valid (isValid=null). Waiting for new one. 17:32:58.587 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: renderThreadPrepared=false and Android surface is not valid (isValid=null). Waiting for new one. 17:32:58.588 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: renderThreadPrepared=false and Android surface is not valid (isValid=null). Waiting for new one. 17:32:58.625 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: Renderer resumed, renderThreadPrepared=false, surface.isValid=null 17:32:58.625 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: renderThreadPrepared=false and Android surface is not valid (isValid=null). Waiting for new one. 17:32:58.643 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: renderThreadPrepared=false and Android surface is not valid (isValid=null). Waiting for new one. 17:32:58.646 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: onSurfaceCreated 17:32:58.646 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: onSurfaceCreated: waiting Android surface to be processed... 17:32:58.647 28395-28669 Mapbox I [maps-android\Mbgl-RenderThread]: Setting up render thread, flags: creatingSurface=true, nativeRenderCreated=false, eglContextMadeCurrent=false, eglContextCreated=false, paused=false 17:32:58.648 28395-28669 Mapbox I [maps-android\Mbgl-EGLConfigChooser]: In emulator: false 17:32:58.650 28395-28669 Mapbox I [maps-android\Mbgl-EglCore]: EGLContext created, client version 3 17:32:58.650 28395-28669 Mapbox I [maps-core]: Using OpenGL render backend 17:32:58.651 28395-28669 Mapbox I [maps-android\Mbgl-RenderThread]: Native renderer created. 17:32:58.651 28395-28395 Mapbox I [maps-android\Mbgl-RenderThread]: onSurfaceCreated: Android surface was processed. 17:32:58.766 28395-28395 Mapbox E [maps-android\LocationPuck2D]: No image holder data for mapbox-location-top-icon! 17:32:58.788 28395-28395 Mapbox E [maps-android\LocationPuck2D]: No image holder data for mapbox-location-top-icon! 17:33:03.415 28395-28670 Mapbox I [tile_store]: Searching for stray files to clean up 17:33:03.418 28395-28670 Mapbox I [tile_store]: Cleanup of stray partial downloads complete 17:33:03.419 28395-28670 Mapbox I [tile_store]: Searching for stale partial downloads to clean up 17:33:03.421 28395-28670 Mapbox I [tile_store]: Cleanup of stray partial downloads complete 17:33:03.784 28395-28419 Mapbox E [events_service]: Events sending aborted after 2 attempts 17:33:03.786 28395-28419 Mapbox E [maps-android\MapTelemetryImpl]: sendTurnstileEvent error: [code: HttpError, message: Failed to connect to events.mapbox.com/0.0.0.0:443]
Screenshot below:
Expected behavior
should be positioned successfully
Notes / preliminary analysis
I tried running the same code on other phones, and it successfully positioned and displayed the current location. It should be that the positioning failed, but I don’t know why.
Additional links and references