Skip to content
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

Updated static map request maximum size. #139

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 106 additions & 106 deletions lib/config/constants.json
Original file line number Diff line number Diff line change
@@ -1,159 +1,159 @@
{
"ACCEPTED_CONFIG_KEYS": {
"encode_polylines": "boolean",
"google_client_id": "string",
"google_channel": "string",
"key": "string",
"proxy": "string",
"secure": "boolean",
"stagger_time": "number"
"encode_polylines": "boolean",
"google_client_id": "string",
"google_channel": "string",
"key": "string",
"proxy": "string",
"secure": "boolean",
"stagger_time": "number"
},

"ACCEPTED_PARAMS": {
"place-search-nearby": {
"keyword": "string",
"language": "string",
"location": "string",
"maxprice": "number",
"minprice": "number",
"name": "string",
"opennow": "boolean",
"keyword": "string",
"language": "string",
"location": "string",
"maxprice": "number",
"minprice": "number",
"name": "string",
"opennow": "boolean",
"pagetoken": "string",
"radius": "number",
"rankby": "string",
"sensor": "string",
"types": "string"
"radius": "number",
"rankby": "string",
"sensor": "string",
"types": "string"
},
"place-search-text": {
"location": "string",
"radius": "string",
"language": "string",
"maxprice": "number",
"minprice": "number",
"opennow": "boolean",
"pagetoken": "string",
"sensor": "string",
"type": "string",
"types": "string",
"location": "string",
"radius": "string",
"language": "string",
"maxprice": "number",
"minprice": "number",
"opennow": "boolean",
"pagetoken": "string",
"sensor": "string",
"type": "string",
"types": "string",
"zagatselected": "string",
"query": "string"
"query": "string"
},
"place-details": {
"placeid": "string",
"placeid": "string",
"extensions": "string",
"language": "string"
"language": "string"
},
"place-autocomplete": {
"input": "string",
"offset": "number",
"location": "string",
"radius": "number",
"language": "string",
"types": "string",
"input": "string",
"offset": "number",
"location": "string",
"radius": "number",
"language": "string",
"types": "string",
"components": "string"
},
"geocode": {
"address": "string",
"address": "string",
"components": "string",
"bounds": "string",
"language": "string",
"region": "string"
"bounds": "string",
"language": "string",
"region": "string"
},
"reverse-geocode": {
"latlng": "string",
"place_id": "string",
"result_type": "string",
"language": "string",
"latlng": "string",
"place_id": "string",
"result_type": "string",
"language": "string",
"location_type": "string"
},
"distance-matrix": {
"origins": "string",
"destinations": "string",
"mode": "string",
"language": "string",
"avoid": "string",
"units": "string",
"origins": "string",
"destinations": "string",
"mode": "string",
"language": "string",
"avoid": "string",
"units": "string",
"departure_time": "date",
"arrival_time": "date",
"traffic_model": "string"
"arrival_time": "date",
"traffic_model": "string"
},
"directions": {
"origin": "string",
"destination": "string",
"mode": "string",
"waypoints": "string",
"alternatives": "boolean",
"avoid": "string",
"language": "string",
"region": "string",
"units": "string",
"origin": "string",
"destination": "string",
"mode": "string",
"waypoints": "string",
"alternatives": "boolean",
"avoid": "string",
"language": "string",
"region": "string",
"units": "string",
"departure_time": "date",
"arrival_time": "date",
"traffic_model": "string"
"arrival_time": "date",
"traffic_model": "string"
},
"elevation": {
"locations": "string",
"path": "string",
"samples": "string"
"path": "string",
"samples": "string"
},
"static-map": {
"center": "string",
"zoom": "number",
"size": "string",
"scale": "number",
"format": "string",
"maptype": "string",
"center": "string",
"zoom": "number",
"size": "string",
"scale": "number",
"format": "string",
"maptype": "string",
"language": "string",
"region": "string",
"markers": "array",
"path": "array",
"visible": "string",
"style": "array"
"region": "string",
"markers": "array",
"path": "array",
"visible": "string",
"style": "array"
},
"timezone": {
"location": "string",
"location": "string",
"timestamp": "number",
"language": "string"
"language": "string"
},
"street-view": {
"location": "string",
"pano": "string",
"size": "string",
"heading": "number",
"fov": "number",
"pitch": "number"
"pano": "string",
"size": "string",
"heading": "number",
"fov": "number",
"pitch": "number"
}

},

"MAX_REQUEST_LENGTHS": {
"directions": 2048,
"distance-matrix": 2048,
"elevation": -1,
"geocode": 2048,
"place-details": 2048,
"directions": 2048,
"distance-matrix": 2048,
"elevation": -1,
"geocode": 2048,
"place-details": 2048,
"place-search-nearby": 2048,
"place-search-text": 2048,
"place-autocomplete": 2048,
"reverse-geocode": 2048,
"static-map": 2048,
"timezone": 2048,
"street-view": 2048
"place-search-text": 2048,
"place-autocomplete": 2048,
"reverse-geocode": 2048,
"static-map": 8096,
"timezone": 2048,
"street-view": 2048
},

"GOOGLEMAPS_ENDPOINTS": {
"directions": "/maps/api/directions/json",
"distance-matrix": "/maps/api/distancematrix/json",
"elevation": "/maps/api/elevation/json",
"geocode": "/maps/api/geocode/json",
"place-details": "/maps/api/place/details/json",
"directions": "/maps/api/directions/json",
"distance-matrix": "/maps/api/distancematrix/json",
"elevation": "/maps/api/elevation/json",
"geocode": "/maps/api/geocode/json",
"place-details": "/maps/api/place/details/json",
"place-search-nearby": "/maps/api/place/nearbysearch/json",
"place-search-text": "/maps/api/place/textsearch/json",
"place-autocomplete": "/maps/api/place/autocomplete/json",
"reverse-geocode": "/maps/api/geocode/json",
"static-map": "/maps/api/staticmap",
"timezone": "/maps/api/timezone/json",
"street-view": "/maps/api/streetview"
"place-search-text": "/maps/api/place/textsearch/json",
"place-autocomplete": "/maps/api/place/autocomplete/json",
"reverse-geocode": "/maps/api/geocode/json",
"static-map": "/maps/api/staticmap",
"timezone": "/maps/api/timezone/json",
"street-view": "/maps/api/streetview"
}

}
20 changes: 10 additions & 10 deletions lib/staticMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ var check = require('check-types');
/**
* Internal modules
*/
var _makeRequest = require('./utils/makeRequest');
var _makeRequest = require('./utils/makeRequest');
var _assignParams = require('./utils/assignParams');
var _jsonParser = require('./utils/jsonParser');
var _jsonParser = require('./utils/jsonParser');
var _parseMarkers = require('./utils/parseMarkers');
var _parseStyles = require('./utils/parseStyles');
var _parsePaths = require('./utils/parsePaths');
var _parseStyles = require('./utils/parseStyles');
var _parsePaths = require('./utils/parsePaths');

var _constants = require('./config/constants');

var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS;
var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS;
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS;
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS;
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS;

var METHOD_KEY = 'static-map';

Expand All @@ -28,7 +28,7 @@ function _errorHandler(callback, error) {
throw error;
}

module.exports = function(params, callback) {
module.exports = function (params, callback) {

if (typeof callback !== "undefined" && callback !== null) {
if (typeof callback !== 'function') {
Expand Down Expand Up @@ -86,20 +86,20 @@ module.exports = function(params, callback) {

if (args.format != null) {
if (args.format != 'png8' && args.format != 'png' && args.format != 'png32' && args.format != 'gif' && args.format != 'jpg' && args.format != 'jpg-baseline') {
return _errorHandler(callback, new Error('Invalid params.format: '+args.format+'. Valid params.format are [png8|png|png32|gif|jpg|jpg-baseline]'));
return _errorHandler(callback, new Error('Invalid params.format: ' + args.format + '. Valid params.format are [png8|png|png32|gif|jpg|jpg-baseline]'));
}
}

if (args.maptype != null) {
args.maptype = args.maptype.toLowerCase();
if (args.maptype !== 'roadmap' && args.maptype !== 'satellite' && args.maptype !== 'terrain' && args.maptype !== 'hybrid') {
return _errorHandler(callback, new Error('Invalid params.maptype: '+args.maptype+'. Valid params.maptype are [roadmap|satellite|terrain|hybrid]'));
return _errorHandler(callback, new Error('Invalid params.maptype: ' + args.maptype + '. Valid params.maptype are [roadmap|satellite|terrain|hybrid]'));
}
}

if (args.style != null) {
try {
args.style = _parseStyles(args.style);
args.style = _parseStyles(args.style)
} catch (ex) {
return _errorHandler(callback, ex);
}
Expand Down
11 changes: 7 additions & 4 deletions lib/utils/makeRequest.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/**
* Node.js native modules
*/
var qs = require('qs');
var qs = require('qs');
var crypto = require('crypto');

function _buildUrl(config, args, path) {

var qsConfig = { indices: false, arrayFormat: 'repeat' };
var qsConfig = {
indices: false,
arrayFormat: 'repeat'
};

if (config.google_client_id && config.google_private_key) {
args.client = config.google_client_id;
Expand All @@ -33,7 +36,7 @@ function _buildUrl(config, args, path) {

// Get the signature, telling it to return the signature in base64 format
var signature = signer.update(path).digest('base64');
signature = signature.replace(/\+/g,'-').replace(/\//g,'_');
signature = signature.replace(/\+/g, '-').replace(/\//g, '_');
path += "&signature=" + signature;
return path;
} else {
Expand All @@ -46,7 +49,7 @@ function _buildUrl(config, args, path) {
/**
* Makes the request to Google Maps API.
*/
module.exports = function(request, config, path, args, callback, requestMaxLength, encoding) {
module.exports = function (request, config, path, args, callback, requestMaxLength, encoding) {
requestMaxLength = requestMaxLength || -1;

var secure = config.secure;
Expand Down
7 changes: 4 additions & 3 deletions lib/utils/parseStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ output = [
]
**/

module.exports = function(styles) {
module.exports = function (styles) {

if (!Array.isArray(styles)) {
throw new Error('styles must be an array');
}

return styles.map(function(style){
return styles.map(function (style) {

var i, len, s = [], keys = ['feature', 'element'];
var i, len, s = [],
keys = ['feature', 'element'];

for (i = 0, len = keys.length; i < len; i++) {
if (style[keys[i]] != null) {
Expand Down