Skip to content

Commit

Permalink
Fixed the Map Styles
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jul 9, 2016
1 parent ffcb659 commit db8aacc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ And here's the comprehensive list of supported functions:

mapbox.show({
accessToken: 'YOUR_API_ACCESS_TOKEN', // see 'Prerequisites' above
style: 'light', // light|dark|satellite|streets , default 'streets' (there is also 'hybrid' for Android)
style: mapbox.MapStyle.DARK, // see the mapbox.MapStyle enum for other options, default mapbox.MapStyle.STREETS
margins: {
left: 40, // default 0
right: 40, // default 0
Expand Down
8 changes: 5 additions & 3 deletions mapbox.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ mapbox._getMapStyle = function(input) {
return Style.LIGHT;
} else if (input === mapbox.MapStyle.DARK) {
return Style.DARK;
} else if (input === mapbox.MapStyle.EMERALD) { // TODO repl with OUTDOOR -- add dropdown to UI
return Style.EMERALD;
} else if (input === mapbox.MapStyle.SATELLITE) { // TODO: also, SATELLITE_STREETS: https://www.mapbox.com/android-sdk/
} else if (input === mapbox.MapStyle.OUTDOORS) {
return Style.OUTDOORS;
} else if (input === mapbox.MapStyle.SATELLITE) {
return Style.SATELLITE;
} else if (input === mapbox.MapStyle.HYBRID || mapbox.MapStyle.SATELLITE_STREETS) {
return Style.SATELLITE_STREETS;
} else {
// default
return Style.MAPBOX_STREETS;
Expand Down
5 changes: 3 additions & 2 deletions mapbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ declare module "nativescript-mapbox" {
*/
enum MapStyle {
DARK,
EMERALD,
HYBRID,
OUTDOORS,
LIGHT,
SATELLITE,
HYBRID, // deprecated, use SATELLITE_STREETS
SATELLITE_STREETS,
STREETS
}

Expand Down
22 changes: 12 additions & 10 deletions mapbox.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ var fs = require("file-system");
var imgSrc = require("image-source");

mapbox._getMapStyle = function(input) {
var version = 9;

if (input === mapbox.MapStyle.LIGHT) {
return MGLStyle.lightStyleURL();
return MGLStyle.lightStyleURLWithVersion(version);
} else if (input === mapbox.MapStyle.DARK) {
return MGLStyle.darkStyleURL();
} else if (input === mapbox.MapStyle.EMERALD) {
return MGLStyle.emeraldStyleURL();
return MGLStyle.darkStyleURLWithVersion(version);
} else if (input === mapbox.MapStyle.OUTDOORS) {
return MGLStyle.outdoorsStyleURLWithVersion(version);
} else if (input === mapbox.MapStyle.SATELLITE) {
return MGLStyle.satelliteStyleURL();
} else if (input === mapbox.MapStyle.HYBRID) {
return MGLStyle.hybridStyleURL();
return MGLStyle.satelliteStyleURLWithVersion(version);
} else if (input === mapbox.MapStyle.HYBRID || mapbox.MapStyle.SATELLITE_STREETS) {
return MGLStyle.satelliteStreetsStyleURLWithVersion(version);
} else {
// default
return MGLStyle.streetsStyleURL();
return MGLStyle.streetsStyleURLWithVersion(version);
}
};

Expand Down Expand Up @@ -210,15 +212,15 @@ mapbox.getTilt = function () {
mapbox.animateCamera = function (arg) {
return new Promise(function (resolve, reject) {
try {

var target = arg.target;
if (target === undefined) {
reject("Please set the 'target' parameter");
return;
}

var cam = MGLMapCamera.camera();

cam.centerCoordinate = CLLocationCoordinate2DMake(target.lat, target.lng);

if (arg.altitude) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-mapbox",
"version": "1.2.0",
"version": "1.2.1",
"description": "Native Maps, by Mapbox.",
"main": "mapbox.js",
"nativescript": {
Expand Down

0 comments on commit db8aacc

Please sign in to comment.