Skip to content

Commit

Permalink
Merge pull request #50 from bradmartin/master
Browse files Browse the repository at this point in the history
Improve the addPolyline color option
  • Loading branch information
EddyVerbruggen authored Oct 28, 2016
2 parents 1f4b30c + b78a131 commit fce5ecc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Draw a polyline. Connect the points given as parameters.
// Draw a two segment line near Amsterdam Central Station
mapbox.addPolyline({
id: 1, // optional, can be used in 'removePolylines'
color: 0xff29a025, //Set the color of the line (default black)
color: '#336699', // Set the color of the line (default black)
width: 7, //Set the width of the line (default 5)
points: [
{
Expand Down
12 changes: 11 additions & 1 deletion mapbox.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var utils = require("utils/utils");
var application = require("application");
var frame = require("ui/frame");
var fs = require("file-system");
var Color = require("color").Color;
var mapbox = require("./mapbox-common");
mapbox._markers = [];
mapbox._polylines = [];
Expand Down Expand Up @@ -606,7 +607,16 @@ mapbox.addPolyline = function (arg, nativeMap) {

var polylineOptions = new com.mapbox.mapboxsdk.annotations.PolylineOptions();
polylineOptions.width(arg.width || 5); // default 5
polylineOptions.color(arg.color || 0xff000000); // default black

// Create android color && default black
var androidColor;
if (arg.color && Color.isValid(arg.color)) {
androidColor = arg.color ? new Color(arg.color).android : new Color('#000').android;
} else {
androidColor = new Color('#000').android;
}

polylineOptions.color(androidColor);
for (var p in points) {
var point = points[p];
polylineOptions.add(new com.mapbox.mapboxsdk.geometry.LatLng(point.lat, point.lng));
Expand Down
6 changes: 3 additions & 3 deletions mapbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ declare module "nativescript-mapbox" {
*/
width?: number;
/**
* Color of the lone, default black (0xff000000).
* Color of the line, default black.
*/
color?: any;
color?: string;
points: LatLng[];
}

Expand Down Expand Up @@ -247,4 +247,4 @@ declare module "nativescript-mapbox" {
export function downloadOfflineRegion(arg: DownloadOfflineRegionOptions): Promise<any>;
export function listOfflineRegions(arg: ListOfflineRegionsOptions): Promise<Array<OfflineRegion>>;
export function deleteOfflineRegion(arg: DeleteOfflineRegionOptions): Promise<any>;
}
}

0 comments on commit fce5ecc

Please sign in to comment.