-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Mapview goes black in offline mode after any region is downloaded. #11511
Comments
@Abhishek284 I'm not able to reproduce this issue: First I download a region: Afterwards I kill the app, turn off wifi and reopen the app: Maps loads correctly. Do you have any more details to reproduce this issue? Are you initialising your map before OnMapReady with the camera position that is found in your offline region? |
@tobrun I have hardcoded a location and moving camera to that point. Something like this below. I am updating the camera position only after getting the OnMapReady callback. Everything works fine unless and until I download any area. Once I download any region, I am just trying to open map view like the same way I did before downloading any region in offline mode, but sadly the map view is black. The same code works in offline mode if there are no downloaded areas, but doesn't work if there are any downloaded areas. [I am not using anything from downloaded regions] Now it gets more tricky here, while downloading any region if I stop the download in the middle, my code works fine in offline mode, inspite of having offline regions partially downloaded. The conclusion being, If I download any offline region fully, my code doesn't work in offline mode.[Map view goes black] I have referred the Offline Manager activity from the following link below to download offline region.Link to demo project Just to mention, I am using AIRMAPS sdk. |
Hi @tobrun I have provided necessary information but the issue is sill labelled as "Needs Information". Please let us know if anything else is needed. Best Regards, |
👍
Once a offline download occurred you need to startup the map with the correct camera position instead of waiting for the OnMapReady callback. OnMapReady will only be executed once a style has been loaded. To do this you will either need to configure your camera position through xml (if the region is not dynamic) else you need to configure your camera position through MapboxMapOptions. Xml <com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="52.0907"
app:mapbox_cameraTargetLng="5.1214"
app:mapbox_cameraZoom="16"/> MapboxMapOptions /**
* Specifies a the initial camera position for the map view.
*
* @param cameraPosition Inital camera position
* @return This
*/
public MapboxMapOptions camera(CameraPosition cameraPosition) {
this.cameraPosition = cameraPosition;
return this;
}
This is because local cache will be used instead of the offline regions and is a works as designed.
This is as mentioned above related to camera position initialisation. Additionally want to add if you leave the viewport of the configured offline region you will also see a black map, this is how offline works and you can however limit/restrict the the ability of the user to move around with gestures. I hope this clears up your issue with offline. We are aware that the current exposed api can be improved and we planning to work to improve the developer experience around this + creating a higher level offline plugin here. Closing this issue as answered. |
@Abhishek284 We were having a similar issue where we would download an offline SAT map but when restarting the app with wifi off we would get a black map and no For example: |
@dsuresh-ap the reason for that is: if no style was provided before onMapReady we will try loading mapbox streets instead. (onMapReady is invoked as part of successfully loading a style). Best practice is to always provide a style url upfront whenever possible. |
Hello There! I am triing to use the online map feature. My problem is that after
and the mapview stays black due to the onMapReady callback was not called. I know that there was a solution for this previously:
But I am using SupportMapFragment to generate MapboxMap object, and I do not able to get it before the callback was called via How could I get the MapboxMap object from SupportMapFragment, before the callback was called? |
@DarthGyuro please do not reply to old closed issue.
This means you are using an old version of our SDK and this statement is no longer true with v7.x versions. One additional note to make this work is that you might need to store your style.json locally instead of using an remote URL. |
I'm sorry to reply here, but I would like to thank you for your help! |
No worries @DarthGyuro, don't hesitate to create an issue in this repository, happy to help :) |
Platform: Android
Airmap sdk version : com.airmap.airmapsdk:airmapsdk:1.0.6 [Airmap internally uses mapbox]
Mapbox ui : com.mapbox.mapboxsdk:mapbox-android-ui:2.2.2
Steps:
Note: Downloading should be 100 percent complete to reproduce this issue. If map is downloaded partially then the issue cannot be reproduced.
The text was updated successfully, but these errors were encountered: