From db8aacc71ee5c0e85f408f81726bd138a07671dc Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Sat, 9 Jul 2016 10:05:08 +0200 Subject: [PATCH] Fixed the Map Styles --- README.md | 2 +- mapbox.android.js | 8 +++++--- mapbox.d.ts | 5 +++-- mapbox.ios.js | 22 ++++++++++++---------- package.json | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 7ecf143..6081cec 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/mapbox.android.js b/mapbox.android.js index b9d40df..1456825 100755 --- a/mapbox.android.js +++ b/mapbox.android.js @@ -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; diff --git a/mapbox.d.ts b/mapbox.d.ts index 7bce19e..fbbab6c 100644 --- a/mapbox.d.ts +++ b/mapbox.d.ts @@ -5,10 +5,11 @@ declare module "nativescript-mapbox" { */ enum MapStyle { DARK, - EMERALD, - HYBRID, + OUTDOORS, LIGHT, SATELLITE, + HYBRID, // deprecated, use SATELLITE_STREETS + SATELLITE_STREETS, STREETS } diff --git a/mapbox.ios.js b/mapbox.ios.js index 6415680..40135c0 100755 --- a/mapbox.ios.js +++ b/mapbox.ios.js @@ -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); } }; @@ -210,7 +212,7 @@ 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"); @@ -218,7 +220,7 @@ mapbox.animateCamera = function (arg) { } var cam = MGLMapCamera.camera(); - + cam.centerCoordinate = CLLocationCoordinate2DMake(target.lat, target.lng); if (arg.altitude) { diff --git a/package.json b/package.json index 77f72f1..d0fd86c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-mapbox", - "version": "1.2.0", + "version": "1.2.1", "description": "Native Maps, by Mapbox.", "main": "mapbox.js", "nativescript": {