Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Little trick for offine examples #6501

Closed
ANSB opened this issue Sep 28, 2016 · 4 comments
Closed

Little trick for offine examples #6501

ANSB opened this issue Sep 28, 2016 · 4 comments
Labels
Android Mapbox Maps SDK for Android

Comments

@ANSB
Copy link

ANSB commented Sep 28, 2016

I'm using Android SDK for offline maps and discover that none of the examples are really correct.
Here's my goal: I'm working on a firefighter App. The App receive Lat and Long of the accident location. It finds fire hidrants all around in order to create the bounds, then download the area. Then it takes accident location, firestation location, ask for the "direction", save polyline coord in SQL, get min and max to get the route bounds, and get it.
Then I unplug Wifi, and let's go.
But, I get an HTTP error...
In fact, all examples MapBox give are NOT real offline examples.

In order to get an Activity which download file, then being able to cut Wifi and use and other activity, you must respect a few points that (I think) must be explained in the examples:

  1. when you download, you must set the style like mapView.setStyleUrl(Style.SATELLITE_STREETS); Because with Offline, the style is defined at download time and NOT at display time. The display will be done using the style you downloaded.
  2. when you display, you must avoid everything which have a link with internet. So the XML code must be:
 _<com.mapbox.mapboxsdk.maps.MapView
    mapbox:zoom="18"
    android:id="@+id/mapview"
    android:layout_margin="2dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />_

Don't put the style and don't call mapView.setStyleUrl or you'll have an HTTP error and this will stop displaying your map.

The problem came from the fact the off line examples show how to download AND display at same time which is confused

Hope this will help and avoid headaches.

@1ec5 1ec5 added the Android Mapbox Maps SDK for Android label Sep 29, 2016
@cammace
Copy link
Contributor

cammace commented Oct 3, 2016

Thanks for reporting this, which version of the SDK are you using? We have recently reduced the amount of logging which occurs during offline usage and fixed a few issues (see #6210, #5781, and #6402). Could you try either the latest 4.2.0-beta.3 or the SNAPSHOT. The reason for some of the HTTP request when an offline regions loaded in would be to check if a more recent tile's available (and update if internets available).

For the map style, you'll need to use the same style for both the offline region you are downloading and the mapview style.

@ANSB
Copy link
Author

ANSB commented Oct 3, 2016

I'm using com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.1@aar
As soon as I finished struggling with a displa (in a few minutes I hope), I'll try with the 4.2.0
Concerning the offline, I've made a suggestion here:
#6550

@ANSB
Copy link
Author

ANSB commented Oct 3, 2016

@cammace I just tested 4.2.0 Beta and it seems to be faster and with less loging. Good!

@cammace
Copy link
Contributor

cammace commented Oct 4, 2016

Awesome glad it works for you, keep an eye open for the final release of 4.2.0!

@cammace cammace closed this as completed Oct 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

3 participants