Socket
Socket
Sign inDemoInstall

googlemaps

Package Overview
Dependencies
49
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.11.1 to 1.12.0

lib/placeSearchNearby.js

80

lib/config/constants.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc