-
Notifications
You must be signed in to change notification settings - Fork 10
Move to ES6 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Move to ES6 #2
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2db2e16
First bunch of migrations to ES6
hansemannn e30ac09
Fix Typo
hansemannn f78eb21
Working Android version!
hansemannn 193de83
Working iOS version!
hansemannn 9e39d69
Use code-initializer
hansemannn 8b7ef97
Merge branch 'master' into es6
hansemannn 745987c
Update annotation.js
hansemannn 0952c9d
Update index.js
hansemannn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: aca95d0d8ce7ca2fd82e83e2cfaaa83799fe5b7a | ||
|
||
COCOAPODS: 1.3.1 | ||
COCOAPODS: 1.4.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const MarkerOptions = require('com.mapbox.mapboxsdk.annotations.MarkerOptions'); | ||
const LatLng = require('com.mapbox.mapboxsdk.geometry.LatLng'); | ||
|
||
export default class Annotation { | ||
constructor(args) { | ||
if (!args.latitude || !args.longitude) { | ||
throw new Error('Missing latitude / longitude'); | ||
} | ||
|
||
this.annotation = new MarkerOptions().setTitle(args.title).setPosition(new LatLng(args.latitude, args.longitude)); | ||
} | ||
|
||
getInstance() { | ||
return this.annotation; | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import MapView from './mapview'; | ||
import Annotation from './annotation'; | ||
|
||
const NativeMapbox = require('com.mapbox.mapboxsdk.Mapbox'); | ||
const Activity = require('android.app.Activity'); | ||
|
||
class Mapbox { | ||
static initialize(apiKey) { | ||
if (!apiKey) { throw new Error('No API-key provided!'); } | ||
NativeMapbox.getInstance(new Activity(Ti.Android.currentActivity), apiKey); | ||
} | ||
} | ||
|
||
export { Annotation, MapView, Mapbox } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const Activity = require('android.app.Activity'); | ||
const NativeMapView = require('com.mapbox.mapboxsdk.maps.MapView'); | ||
const MapboxMapOptions = require('com.mapbox.mapboxsdk.maps.MapboxMapOptions'); | ||
const LatLng = require('com.mapbox.mapboxsdk.geometry.LatLng'); | ||
const LatLngBounds = require('com.mapbox.mapboxsdk.geometry.LatLngBounds'); | ||
const CameraPositionBuilder = require('com.mapbox.mapboxsdk.camera.CameraPosition.Builder'); | ||
const OnMapReadyCallback = require('com.mapbox.mapboxsdk.maps.OnMapReadyCallback'); | ||
|
||
export default class MapView { | ||
constructor(args) { | ||
let options = new MapboxMapOptions(); | ||
|
||
if (args.region && args.region.latitude && args.region.longitude) { | ||
const latLong = new LatLng(args.region.latitude, args.region.longitude); | ||
const cameraBuilder = new CameraPositionBuilder().zoom(args.region.zoomLevel || 7).bearing(args.region.direction || 0).target(latLong); | ||
options = options.camera(cameraBuilder.build()); | ||
} | ||
this.mapView = new NativeMapView(new Activity(Ti.Android.currentActivity), options); | ||
} | ||
|
||
set visibleCoordinateBounds(args) { | ||
this.mapView.getMapAsync(new OnMapReadyCallback({ | ||
onMapReady: (mapboxMap) => { | ||
const bounds = LatLngBounds.from(args.northEast.latitude, args.northEast.longitude, args.southWest.latitude, args.southWest.longitude); | ||
mapboxMap.setLatLngBoundsForCameraTarget(bounds); | ||
} | ||
})); | ||
} | ||
|
||
addAnnotation(annotation) { | ||
this.mapView.getMapAsync(new OnMapReadyCallback({ | ||
onMapReady: (mapboxMap) => { | ||
mapboxMap.addMarker(annotation); | ||
} | ||
})); | ||
} | ||
|
||
getInstance() { | ||
return this.mapView; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const MGLPointAnnotation = require('Mapbox/MGLPointAnnotation'); | ||
const MGLCoordinateBoundsMake = require('Mapbox').MGLCoordinateBoundsMake; | ||
const CLLocationCoordinate2DMake = require('CoreLocation').CLLocationCoordinate2DMake; | ||
|
||
export default class Annotation { | ||
constructor(args) { | ||
this.annotation = new MGLPointAnnotation(); | ||
|
||
if (!args.latitude || !args.longitude) { | ||
throw 'Missing latitude / longitude'; | ||
} | ||
|
||
this.annotation.coordinate = CLLocationCoordinate2DMake(args.latitude, args.longitude); | ||
this.annotation.title = args.title; | ||
this.annotation.canShowCallout = true; | ||
|
||
// Expose more? See https://www.mapbox.com/ios-sdk/api/3.7.3/Classes/MGLPointAnnotation.html | ||
} | ||
|
||
getInstance() { | ||
return this.annotation; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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 } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here