Conversation
| const Mapbox = require('com.mapbox.mapboxsdk.Mapbox'); | ||
| const Activity = require('android.app.Activity'); | ||
|
|
||
| Mapbox.getInstance(new Activity(Ti.Android.currentActivity), 'YOUR_MAPBOX_ACCESS_TOKEN'); |
There was a problem hiding this comment.
I'm not sure if this will work correctly here, since it may have to run delayed for the current activity stuff to work. That's why I did it lazily inside the createView call.
There was a problem hiding this comment.
I was hoping it is executed once anything is imported, which seems to work okay. The problem is that there are mapbox API's that do not require a map-view, like geocoders. Maybe do an initialize method? iOS can actually also be configured by code, so I'd remove the plist-key and use one central method.
There was a problem hiding this comment.
Doing this one:
import MapView from './mapview';
import Annotation from './annotation';
const MGLAccountManager = require('Mapbox/MGLAccountManager');
class Mapbox {
static initialize(apiKey) {
if (!apiKey) { throw 'No API-key provided!'; }
MGLAccountManager.setAccessToken(apiKey);
}
}
export { Annotation, MapView, Mapbox }| Mapbox.getInstance(new Activity(Ti.Android.currentActivity), 'YOUR_MAPBOX_ACCESS_TOKEN'); | ||
| class Mapbox { | ||
| static initialize(apiKey) { | ||
| if (!apiKey) { throw 'No API-key provided!'; } |
There was a problem hiding this comment.
You're not supposed to throw raw strings, but wrap them in an Error object:
if (!apiKey) { throw new Error('No API-key provided!'); }|
|
||
| class Mapbox { | ||
| static initialize(apiKey) { | ||
| if (!apiKey) { throw 'No API-key provided!'; } |
|
I don't have write access, so can't merge. CR seems fine. |
|
Thanks for the review @sgtcoolguy! We are blocked by the Hyperloop 3.1.0 release but can merge once released (pending QE testing). |
Ready to review! Requires Hyperloop 3.1.0 Beta 2 (or later).