googlemaps
Advanced tools
Comparing version 1.11.1 to 1.12.0
{ | ||
"ACCEPTED_CONFIG_KEYS": { | ||
@@ -14,3 +13,3 @@ "encode_polylines": "boolean", | ||
"ACCEPTED_PARAMS": { | ||
"place-search": { | ||
"place-search-nearby": { | ||
"keyword": "string", | ||
@@ -29,2 +28,16 @@ "language": "string", | ||
}, | ||
"place-search-text": { | ||
"location": "string", | ||
"radius": "string", | ||
"language": "string", | ||
"maxprice": "number", | ||
"minprice": "number", | ||
"opennow": "boolean", | ||
"pagetoken": "string", | ||
"sensor": "string", | ||
"type": "string", | ||
"types": "string", | ||
"zagatselected": "string", | ||
"query": "string" | ||
}, | ||
"place-details": { | ||
@@ -36,9 +49,9 @@ "placeid": "string", | ||
"place-autocomplete": { | ||
"input": "string", | ||
"offset": "number", | ||
"location": "string", | ||
"radius": "number", | ||
"language": "string", | ||
"types": "string", | ||
"components":"string" | ||
"input": "string", | ||
"offset": "number", | ||
"location": "string", | ||
"radius": "number", | ||
"language": "string", | ||
"types": "string", | ||
"components": "string" | ||
}, | ||
@@ -86,4 +99,4 @@ "geocode": { | ||
"locations": "string", | ||
"path": "string", | ||
"samples": "string" | ||
"path": "string", | ||
"samples": "string" | ||
}, | ||
@@ -105,7 +118,7 @@ "static-map": { | ||
"timezone": { | ||
"location": "string", | ||
"timestamp":"number", | ||
"language": "string" | ||
"location": "string", | ||
"timestamp": "number", | ||
"language": "string" | ||
}, | ||
"street-map": { | ||
"street-view": { | ||
"location": "string", | ||
@@ -121,15 +134,32 @@ "pano": "string", | ||
"MAX_REQUEST_LENGTHS": { | ||
"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 | ||
}, | ||
"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", | ||
"place-search": "/maps/api/place/nearbysearch/json", | ||
"place-autocomplete":"/maps/api/place/autocomplete/json", | ||
"static-map": "/maps/api/staticmap", | ||
"timezone": "/maps/api/timezone/json", | ||
"street-view": "/maps/api/streetview" | ||
"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" | ||
} | ||
} |
@@ -18,3 +18,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'directions'; | ||
@@ -35,3 +37,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['directions']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -56,4 +58,4 @@ // validate directions specific args | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['directions'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -18,3 +18,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'distance-matrix'; | ||
@@ -35,3 +37,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['distance-matrix']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -56,4 +58,4 @@ // validate distance matrix args | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['distance-matrix'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -18,3 +18,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'elevation'; | ||
@@ -35,3 +37,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['elevation']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -46,4 +48,4 @@ if (args.locations == null) { | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['elevation'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -17,3 +17,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'geocode'; | ||
@@ -30,3 +32,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['geocode']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -37,4 +39,4 @@ if (!args.address && !args.components) { | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['geocode'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -21,5 +21,7 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var api = { | ||
placeSearch: require('./placeSearch'), | ||
placeSearchText: require('./placeSearchText'), | ||
placeSearch: require('./placeSearchNearby'), | ||
placeDetails: require('./placeDetails'), | ||
@@ -87,3 +89,12 @@ placeAutocomplete: require('./placeAutocomplete'), | ||
/** | ||
* Endpoint: /maps/api/place/textsearch/json | ||
* Google documentation reference: https://developers.google.com/places/documentation/search | ||
* | ||
* TODO: Maps API for Work customers should not include a client or signature parameter with their requests. | ||
* TODO: params zagatselected | ||
*/ | ||
GoogleMapsAPI.prototype.placeSearchText = api.placeSearchText | ||
/** | ||
* | ||
* Endpoint: '/maps/api/place/details/json' | ||
@@ -259,3 +270,3 @@ * Google documentation reference: https://developers.google.com/places/documentation/details | ||
_makeRequest(request, config, GOOGLEMAPS_ENDPOINTS['elevation'], args, _jsonParser(callback)); | ||
_makeRequest(request, config, GOOGLEMAPS_ENDPOINTS['elevation'], args, _jsonParser(callback), MAX_REQUEST_LENGTHS['elevation']); | ||
@@ -262,0 +273,0 @@ } else { |
@@ -17,3 +17,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'place-autocomplete'; | ||
@@ -34,3 +36,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['place-autocomplete']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -41,4 +43,4 @@ if (args.input == null) { | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['place-autocomplete'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -17,3 +17,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'place-details'; | ||
@@ -34,3 +36,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['place-details']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -41,4 +43,4 @@ if (args.placeid == null) { | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['place-details'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -17,3 +17,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'reverse-geocode'; | ||
@@ -30,3 +32,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['reverse-geocode']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -37,4 +39,4 @@ if (args.latlng == null && args.place_id == null) { | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['geocode'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -20,3 +20,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'static-map'; | ||
@@ -46,3 +48,3 @@ function _errorHandler(callback, error) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['static-map']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -116,4 +118,4 @@ // If a marker param or path param is provided then center and zoom param is not required | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['static-map'], args, callback, 'binary'); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, callback, MAX_REQUEST_LENGTHS[METHOD_KEY], 'binary'); | ||
}; |
@@ -17,3 +17,6 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'street-view'; | ||
function _errorHandler(callback, error) { | ||
@@ -42,3 +45,3 @@ if (typeof callback === 'function') { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['street-map']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -74,4 +77,4 @@ if (args.location == null && args.pano == null) { | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['street-view'], args, callback, 'binary'); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, callback, MAX_REQUEST_LENGTHS[METHOD_KEY], 'binary'); | ||
}; |
@@ -17,3 +17,5 @@ /** | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
var MAX_REQUEST_LENGTHS = _constants.MAX_REQUEST_LENGTHS; | ||
var METHOD_KEY = 'timezone'; | ||
@@ -34,3 +36,3 @@ module.exports = function(params, callback) { | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS['timezone']); | ||
var args = _assignParams({}, params, ACCEPTED_PARAMS[METHOD_KEY]); | ||
@@ -44,4 +46,4 @@ if (args.location == null) { | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['timezone'], args, _jsonParser(callback)); | ||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS[METHOD_KEY], args, _jsonParser(callback), MAX_REQUEST_LENGTHS[METHOD_KEY]); | ||
}; |
@@ -7,7 +7,2 @@ /** | ||
// TODO | ||
// see if this limit needs to be bound to the specific API call, Ex.: distance has a limit of 2000 | ||
var REQUEST_MAX_LENGTH = 2048; | ||
function _buildUrl(config, args, path) { | ||
@@ -55,3 +50,4 @@ | ||
*/ | ||
module.exports = function(request, config, path, args, callback, encoding) { | ||
module.exports = function(request, config, path, args, callback, requestMaxLength, encoding) { | ||
requestMaxLength = requestMaxLength || -1; | ||
@@ -68,4 +64,4 @@ var secure = config.secure; | ||
if (path.length > REQUEST_MAX_LENGTH) { | ||
error = new Error('Request too long for google to handle (' + REQUEST_MAX_LENGTH + ' characters).'); | ||
if (requestMaxLength != -1 && path.length > requestMaxLength) { | ||
error = new Error('Request too long for google to handle (' + requestMaxLength + ' characters).'); | ||
if (typeof callback === 'function') { | ||
@@ -72,0 +68,0 @@ return callback(error); |
@@ -26,4 +26,8 @@ var travelUtils = {} | ||
args.avoid = args.avoid.toLowerCase(); | ||
if (args.avoid !== 'tolls' && args.avoid !== 'highways' && args.avoid !== 'ferries') { | ||
throw new Error('Invalid params.avoid: '+args.avoid+'. Valid params.avoid are [tolls|highways|ferries]'); | ||
var argsArray = args.avoid.split('|'); | ||
for (var argIdx in argsArray) { | ||
var argName = argsArray[argIdx]; | ||
if (argName !== 'tolls' && argName !== 'highways' && argName !== 'ferries') { | ||
throw new Error('Invalid params.avoid: ' + argName + '. Valid params.avoid are [tolls|highways|ferries]'); | ||
} | ||
} | ||
@@ -70,2 +74,2 @@ } | ||
module.exports = travelUtils; | ||
module.exports = travelUtils; |
{ | ||
"name": "googlemaps", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"main": "lib/index", | ||
@@ -36,3 +36,3 @@ "description": "A simple way to query the Google Maps API from Node.js", | ||
"qs": "^4.0.0", | ||
"request": "~2.44.0", | ||
"request": "^2.79.0", | ||
"waitress": ">=0.0.2" | ||
@@ -39,0 +39,0 @@ }, |
@@ -35,2 +35,3 @@ [![Build Status](https://travis-ci.org/moshen/node-googlemaps.svg?branch=master)](https://travis-ci.org/moshen/node-googlemaps) | ||
* [Place autocomplete](https://developers.google.com/places/web-service/autocomplete) | ||
* [Place text search](https://developers.google.com/places/web-service/search#TextSearchRequests) | ||
@@ -180,3 +181,3 @@ [Google Maps Image API](https://developers.google.com/maps/documentation/imageapis/) | ||
Please refer to the code, [tests](http://github.com/moshen/node-googlemaps/tree/master/test/) and the [Google Maps API docs](http://code.google.com/apis/maps/documentation/webservices/index.html) for further usage information. | ||
Please refer to the code, [tests](http://github.com/moshen/node-googlemaps/tree/master/test/) and the [Google Maps API docs](https://developers.google.com/maps/web-services/) for further usage information. | ||
@@ -183,0 +184,0 @@ |
59687
28
1339
202
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.0(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedbl@0.9.5(transitive)
- Removedboom@0.4.2(transitive)
- Removedcaseless@0.6.0(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcryptiles@0.2.2(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedforever-agent@0.5.2(transitive)
- Removedform-data@0.1.4(transitive)
- Removedhawk@1.1.1(transitive)
- Removedhoek@0.9.1(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedmime@1.2.11(transitive)
- Removedmime-types@1.0.2(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.4.0(transitive)
- Removedqs@1.2.2(transitive)
- Removedquerystringify@2.2.0(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedrequest@2.44.0(transitive)
- Removedrequires-port@1.0.0(transitive)
- Removedsntp@0.2.4(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedtough-cookie@4.1.4(transitive)
- Removedtunnel-agent@0.4.3(transitive)
- Removeduniversalify@0.2.0(transitive)
- Removedurl-parse@1.5.10(transitive)
Updatedrequest@^2.79.0