New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

googlemapsutil

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

googlemapsutil - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

lib/staticmaps.js

12

googlemapsutil.js

@@ -11,3 +11,4 @@ /*!

, Elevation = require('./lib/elevation.js')
, Geocoding = require('./lib/geocoding.js');
, Geocoding = require('./lib/geocoding.js')
, Timezone = require('./lib/timezone.js');

@@ -17,3 +18,4 @@ var directions = new Directions()

, elevation = new Elevation()
, geocoding = new Geocoding();
, geocoding = new Geocoding()
, timezone = new Timezone();

@@ -25,2 +27,3 @@ var services = [];

services.push(geocoding);
services.push(timezone);

@@ -65,3 +68,7 @@ var gmaputil = {

geocoding.reverseGeocoding(lat, lng, options, cb, sensor, isHttps, isRequest);
},
timezone: function(lat, lng, timestamp, options, cb, sensor, isHttps, isRequest) {
timezone.timezone(lat, lng, timestamp, options, cb, sensor, isHttps, isRequest);
}
};

@@ -75,2 +82,3 @@

module.exports.Geocoding = Geocoding;
module.exports.Timezone = Timezone;

38

lib/_googlemaps.js

@@ -39,14 +39,20 @@ /*!

};
Gmap.prototype._cvtAddress = function(address) {
Gmap.prototype._cvtObject = function(obj) {
var self = this;
var fnAddress = function(addr) {
if (objectutil.isObject(addr) === true) {
if (!addr.lat || !addr.lng) {
var err = new Error('lat lng is not set');
throw err;
var fnObj = function(obj) {
if (objectutil.isObject(obj) === true) {
if (obj.lat && obj.lng) {
return self._cvtLatLng(obj.lat, obj.lng);
} else if (obj.sw && obj.ne) {
var val = '';
val += fnObj(obj.sw);
val += '|';
val += fnObj(obj.ne);
return val;
} else {
return querystring.stringify(obj, '|', ':');
}
return self._cvtLatLng(addr.lat, addr.lng);
} else {
return addr;
return obj;
}

@@ -56,11 +62,11 @@ };

var param = '';
if (objectutil.isArray(address)) {
for (var i = 0; i < address.length; i++) {
if (objectutil.isArray(obj)) {
for (var i = 0; i < obj.length; i++) {
if (i > 0) {
param += '|';
}
param += fnAddress(address[i]);
param += fnObj(obj[i]);
}
} else {
param += fnAddress(address);
param += fnObj(obj);
}

@@ -76,3 +82,7 @@ return param;

for (var key in src) {
dst[key] = src[key];
if (objectutil.isObject(src[key]) === true) {
dst[key] = this._cvtObject(src[key]);
} else {
dst[key] = src[key];
}
}

@@ -79,0 +89,0 @@ }

@@ -49,9 +49,9 @@ /*!

var params = {};
params.origin = this._cvtAddress(origin);
params.destination = this._cvtAddress(destination);
params.origin = this._cvtObject(origin);
params.destination = this._cvtObject(destination);
this._setOptions(options, params);
if (params.waypoints && objectutil.isArray(params.waypoints) === true) {
params.waypoints = this._cvtWaypoints(options.waypoints);
}
//if (params.waypoints && objectutil.isArray(params.waypoints) === true) {
// params.waypoints = this._cvtWaypoints(options.waypoints);
// }
params.sensor = sensor;

@@ -58,0 +58,0 @@

@@ -8,4 +8,3 @@ /*!

var Gmap = require('./_googlemaps'),
__extends = require('./_extends'),
objectutil = require('./objectutil');
__extends = require('./_extends');

@@ -34,4 +33,4 @@ var DistanceMatrix = (function (_super) {

try {
params.origins = this._cvtAddress(origins);
params.destinations = this._cvtAddress(destinations);
params.origins = this._cvtObject(origins);
params.destinations = this._cvtObject(destinations);
} catch (err) {

@@ -38,0 +37,0 @@ if (cb) {

@@ -8,4 +8,3 @@ /*!

var Gmap = require('./_googlemaps'),
__extends = require('./_extends'),
objectutil = require('./objectutil');
__extends = require('./_extends');

@@ -26,6 +25,6 @@ var Elevation = (function (_super) {

if (locations) {
params.locations = this._cvtAddress(locations);
params.locations = this._cvtObject(locations);
}
if (path) {
params.path = this._cvtAddress(path);
params.path = this._cvtObject(path);
params.samples = samples;

@@ -32,0 +31,0 @@ }

@@ -19,23 +19,2 @@ /*!

Geocoding.prototype._cvtComponents = function(components) {
if (!components) {
return;
}
if (objectutil.isObject(components) === false) {
return;
}
var components = components;
var filter = '';
for (var key in components) {
if (filter.length > 0) {
filter += '|';
}
filter += key + ':' + components[key];
}
if (filter.length > 0) {
return filter;
} else {
return;
}
};

@@ -52,20 +31,3 @@ Geocoding.prototype._geocoding = function(address, latlng, options, cb, sensor, isHttps, isRequest) {

this._setOptions(options, params);
if (params.bounds && objectutil.isObject(params.bounds) === true) {
var bounds = params.bounds;
if (bounds.sw && bounds.sw.lat && bounds.sw.lng
&& bounds.ne && bounds.ne.lat && bounds.ne.lng) {
params.bounds = '';
params.bounds += this._cvtLatLng(bounds.sw.lat, bounds.sw.lng);
params.bounds += '|'
params.bounds += this._cvtLatLng(bounds.ne.lat, bounds.ne.lng);
}
}
if (params.components && objectutil.isObject(params.components) === true) {
var components = this._cvtComponents(params.components);
if (components) {
params.components = components;
}
}
params.sensor = sensor;
this._request(params, cb, isHttps, isRequest);

@@ -72,0 +34,0 @@ };

{
"name": "googlemapsutil",
"version": "0.1.3",
"version": "0.1.4",
"description": "utility to use google map easily",

@@ -5,0 +5,0 @@ "main": "googlemapsutil.js",

// call api
var gmaputil = require('googlemapsutil');
var gmaputil = require('../googlemapsutil');

@@ -38,4 +38,6 @@ // call api from class object

// reverse geocoding
gmaputil.reverseGeocoding(40.714224,-73.961452, null, cb);
gmaputil.reverseGeocoding(40.714224, -73.961452, null, cb);
// time zone
gmaputil.timezone(39.6034810, -119.6822510, 1331161200, null, cb);

@@ -42,0 +44,0 @@ // change output format

@@ -11,3 +11,3 @@ // call api from class object

var Directions = require('googlemapsutil').Directions;
var Directions = require('../googlemapsutil').Directions;
directions = new Directions();

@@ -19,3 +19,3 @@ // directions api sample

// distance matrix api sample
var Distancematrix = require('googlemapsutil').Distancematrix;
var Distancematrix = require('../googlemapsutil').Distancematrix;
distancematrix = new Distancematrix();

@@ -25,3 +25,3 @@ distancematrix.distancematrix(['Vancouver+BC', 'Seattle'], ['San+Francisco', 'Victoria+BC'], {mode: 'bicycling', language: 'fr-FR'}, cb);

// elevation api sample
var Elevation = require('googlemapsutil').Elevation;
var Elevation = require('../googlemapsutil').Elevation;
elevation = new Elevation();

@@ -37,3 +37,3 @@ // locations

// geocoding api sample
var Geocoding = require('googlemapsutil').Geocoding;
var Geocoding = require('../googlemapsutil').Geocoding;
geocoding = new Geocoding();

@@ -40,0 +40,0 @@

@@ -11,3 +11,3 @@ // call api from class object

var Directions = require('googlemapsutil').Directions;
var Directions = require('../googlemapsutil').Directions;
directions = new Directions();

@@ -19,3 +19,3 @@ // directions api sample

// distance matrix api sample
var Distancematrix = require('googlemapsutil').Distancematrix;
var Distancematrix = require('../googlemapsutil').Distancematrix;
distancematrix = new Distancematrix();

@@ -25,3 +25,3 @@ distancematrix.distancematrix(['Vancouver+BC', 'Seattle'], ['San+Francisco', 'Victoria+BC'], {mode: 'bicycling', language: 'fr-FR'}, cb, null, null, false);

// elevation api sample
var Elevation = require('googlemapsutil').Elevation;
var Elevation = require('../googlemapsutil').Elevation;
elevation = new Elevation();

@@ -37,12 +37,12 @@ // locations

// geocoding api sample
var Geocoding = require('googlemapsutil').Geocoding;
var Geocoding = require('../googlemapsutil').Geocoding;
geocoding = new Geocoding();
// geocoding
geocoding.geocoding('1600+Amphitheatre+Parkway,+Mountain+View,+CA', null, cb, null, null, false);
//geocoding.geocoding('1600+Amphitheatre+Parkway,+Mountain+View,+CA', null, cb, null, null, false);
// geocoding with components filter
geocoding.geocoding('Torun', {components: {administrative_area:'TX', country:'US'}}, null, cb, null, null, false);
geocoding.geocoding('Torun', {components: {administrative_area:'TX', country:'US'}}, cb, null, null, false);
// geocoding components filter only
geocoding.geocoding(null, {components: {route:'Annegatan', administrative_area:'Helsinki',country:'Finland'}}, null, cb, null, null, false);
geocoding.geocoding(null, {components: {route:'Annegatan', administrative_area:'Helsinki',country:'Finland'}}, cb, null, null, false);

@@ -49,0 +49,0 @@ // reverse geocoding

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc