Skip to content

Commit

Permalink
Styles API Support. Fixes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Mar 25, 2016
1 parent 3f0efec commit 8f1c266
Show file tree
Hide file tree
Showing 26 changed files with 957 additions and 29 deletions.
24 changes: 23 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,42 @@
// place, so that we could concievably update this for API layout
// revisions.
module.exports.DEFAULT_ENDPOINT = 'https://api.mapbox.com';

module.exports.API_GEOCODING_FORWARD = '/geocoding/v5/{dataset}/{query}.json{?proximity,country,types}';
module.exports.API_GEOCODING_REVERSE = '/geocoding/v5/{dataset}/{longitude},{latitude}.json{?types}';

module.exports.API_DIRECTIONS = '/v4/directions/{profile}/{encodedWaypoints}.json{?alternatives,instructions,geometry,steps}';
module.exports.API_DISTANCE = '/distances/v1/mapbox/{profile}';

module.exports.API_SURFACE = '/v4/surface/{mapid}.json{?layer,fields,points,geojson,interpolate,encoded_polyline}';

module.exports.API_UPLOADS = '/uploads/v1/{owner}';
module.exports.API_UPLOAD = '/uploads/v1/{owner}/{upload}';
module.exports.API_UPLOAD_CREDENTIALS = '/uploads/v1/{owner}/credentials';

module.exports.API_MATCHING = '/matching/v4/{profile}.json';

module.exports.API_DATASET_DATASETS = '/datasets/v1/{owner}';
module.exports.API_DATASET_DATASET = '/datasets/v1/{owner}/{dataset}';
module.exports.API_DATASET_FEATURES = '/datasets/v1/{owner}/{dataset}/features{?reverse,limit,start}';
module.exports.API_DATASET_FEATURE = '/datasets/v1/{owner}/{dataset}/features/{id}';

module.exports.API_TILESTATS_STATISTICS = '/tilestats/v1/{owner}/{tileset}';
module.exports.API_TILESTATS_LAYER = '/tilestats/v1/{owner}/{tileset}/{layer}';
module.exports.API_TILESTATS_ATTRIBUTE = '/tilestats/v1/{owner}/{tileset}/{layer}/{attribute}';
module.exports.API_STATIC = '/v4/{mapid}{+overlay}/{+xyz}/{width}x{height}{+retina}{.format}';

module.exports.API_STATIC = '/v4/{mapid}{+overlay}/{+xyz}/{width}x{height}{+retina}{.format}{?api_token}';

module.exports.API_STYLES_LIST = '/styles/v1/{owner}';
module.exports.API_STYLES_CREATE = '/styles/v1/{owner}';
module.exports.API_STYLES_READ = '/styles/v1/{owner}/{styleid}';
module.exports.API_STYLES_UPDATE = '/styles/v1/{owner}/{styleid}';
module.exports.API_STYLES_DELETE = '/styles/v1/{owner}/{styleid}';
module.exports.API_STYLES_EMBED = '/styles/v1/{owner}/{styleid}.html{?zoomwheel,title,access_token}';
module.exports.API_STYLES_SPRITE = '/styles/v1/{owner}/{styleid}/sprite{+retina}{.format}';
module.exports.API_STYLES_SPRITE_ADD_ICON = '/styles/v1/{owner}/{styleid}/sprite/{iconName}';
module.exports.API_STYLES_SPRITE_DELETE_ICON = '/styles/v1/{owner}/{styleid}/sprite/{iconName}';

module.exports.API_STYLES_FONT_GLYPH_RANGES = '/fonts/v1/{owner}/{font}/{start}-{end}.pbf'

module.exports.API_STYLES_SPRITE_DELETE_ICON = '/styles/v1/{owner}/{styleid}/sprite/{iconName}';
4 changes: 2 additions & 2 deletions lib/encode_overlay.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var invariant = require('invariant'),
var invariant = require('../vendor/invariant'),
invariantLocation = require('./invariant_location'),
polyline = require('polyline'),
polyline = require('../vendor/polyline'),
geojsonhint = require('geojsonhint/object');

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/invariant_location.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var invariant = require('invariant');
var invariant = require('../vendor/invariant');

/**
* Given an object that should be a location, ensure that it has
Expand Down
2 changes: 1 addition & 1 deletion lib/make_service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var invariant = require('invariant');
var invariant = require('../vendor/invariant');
var constants = require('./constants');
var client = require('./client');
var getUser = require('./get_user');
Expand Down
2 changes: 1 addition & 1 deletion lib/mapbox.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var makeClient = require('./make_service');
var xtend = require('xtend/mutable');
var xtend = require('../vendor/xtend').extendMutable;
var MapboxGeocoding = require('./services/geocoding');
var MapboxSurface = require('./services/surface');
var MapboxDirections = require('./services/directions');
Expand Down
4 changes: 2 additions & 2 deletions lib/services/datasets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var invariant = require('invariant'),
var invariant = require('../../vendor/invariant'),
geojsonhint = require('geojsonhint/object'),
hat = require('hat'),
hat = require('../../vendor/hat'),
makeService = require('../make_service'),
constants = require('../constants');

Expand Down
2 changes: 1 addition & 1 deletion lib/services/directions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var invariant = require('invariant'),
var invariant = require('../../vendor/invariant'),
formatPoints = require('../format_points'),
makeService = require('../make_service'),
constants = require('../constants');
Expand Down
2 changes: 1 addition & 1 deletion lib/services/distance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var invariant = require('invariant'),
var invariant = require('../../vendor/invariant'),
makeService = require('../make_service'),
constants = require('../constants');

Expand Down
2 changes: 1 addition & 1 deletion lib/services/geocoding.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var invariant = require('invariant'),
var invariant = require('../../vendor/invariant'),
makeService = require('../make_service'),
constants = require('../constants');

Expand Down
2 changes: 1 addition & 1 deletion lib/services/matching.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var invariant = require('invariant'),
var invariant = require('../../vendor/invariant'),
geojsonhint = require('geojsonhint/object'),
makeService = require('../make_service'),
constants = require('../constants');
Expand Down
10 changes: 5 additions & 5 deletions lib/services/static.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var invariant = require('invariant'),
xtend = require('xtend'),
var invariant = require('../../vendor/invariant'),
xtend = require('../../vendor/xtend').extend,
uriTemplate = require('rest/util/uriTemplate'),
encodeOverlay = require('../encode_overlay'),
invariantLocation = require('../invariant_location'),
Expand Down Expand Up @@ -81,15 +81,15 @@ MapboxStatic.prototype.getStaticURL = function(mapid, width, height, position, o
mapid: mapid,
width: width,
xyz: xyz,
height: height
height: height,
access_token: this.accessToken
});

if (params.retina === true) {
params.retina = '@2x';
}

return this.endpoint + uriTemplate.expand(constants.API_STATIC, params) +
'?access_token=' + this.accessToken;
return this.endpoint + uriTemplate.expand(constants.API_STATIC, params);
};

module.exports = MapboxStatic;
Loading

0 comments on commit 8f1c266

Please sign in to comment.