googlemapsutil
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -76,6 +76,5 @@ /*! | ||
staticmapas: function(parameters, cb, sensor, isHttps, isRequest) { | ||
timezone.staticmaps(parameters, cb, sensor, isHttps, isRequest); | ||
staticmaps.staticmaps(parameters, cb, sensor, isHttps, isRequest); | ||
} | ||
}; | ||
@@ -82,0 +81,0 @@ |
@@ -6,7 +6,12 @@ /*! | ||
*/ | ||
var config = require('../config.json'), | ||
httputil = require('./httputil'), | ||
querystring = require('querystring'), | ||
objectutil = require('./objectutil'); | ||
var config = require('../config.json') | ||
, httputil = require('./httputil') | ||
, querystring = require('querystring') | ||
, objectutil = require('./objectutil') | ||
, mapparams = require('./_mapparams'); | ||
querystring.escape = function(str) { | ||
return str; | ||
}; | ||
var Gmap = (function () { | ||
@@ -54,3 +59,16 @@ function Gmap() { | ||
} else { | ||
return querystring.stringify(obj, '|', ':'); | ||
var key; | ||
var val; | ||
if (obj.points) { | ||
key = 'points'; | ||
obj.points = self._cvtObject(obj.points); | ||
} else if (obj.locations) { | ||
key = 'locations'; | ||
obj.locations = self._cvtObject(obj.locations); | ||
} | ||
key += ':'; | ||
val = querystring.stringify(obj, '|', ':'); | ||
val = querystring.unescape(val); | ||
val = val.replace(key, ''); | ||
return val; | ||
} | ||
@@ -83,6 +101,27 @@ } else { | ||
if (objectutil.isObject(src[key]) === true) { | ||
dst[key] = this._cvtObject(src[key]); | ||
if (mapparams.isDuplicate(key) === true && objectutil.isArray(src[key]) === true) { | ||
var str = ''; | ||
var strtmp; | ||
var obj = {}; | ||
for (var i = 0; i < src[key].length; i++) { | ||
strtmp = ''; | ||
obj[key] = src[key][i]; | ||
if (i > 0) { | ||
strtmp += '&'; | ||
strtmp += key; | ||
strtmp += '='; | ||
} | ||
strtmp += this._cvtObject(src[key][i]); | ||
str += strtmp; | ||
} | ||
dst[key] = str; | ||
} else { | ||
dst[key] = this._cvtObject(src[key]); | ||
} | ||
} else { | ||
dst[key] = src[key]; | ||
} | ||
if (dst[key] && objectutil.isString(dst[key]) === true) { | ||
dst[key] = dst[key].replace('%2C', ','); | ||
} | ||
} | ||
@@ -115,2 +154,11 @@ } | ||
}; | ||
Gmap.prototype.escape = function(str) { | ||
if (!str) { | ||
return str; | ||
} | ||
var rep; | ||
rep = str.replace(/\|/g, '%7C'); | ||
return rep; | ||
}; | ||
@@ -144,5 +192,8 @@ Gmap.prototype._request = function(params, cb, isHttps, isRequest, isOutput) { | ||
} | ||
paramurl = querystring.stringify(params); | ||
_paramurl = querystring.stringify(this._params); | ||
// escape string for google rule | ||
paramurl = this.escape(paramurl); | ||
_paramurl = this.escape(_paramurl); | ||
if (paramurl) { | ||
@@ -149,0 +200,0 @@ if (_paramurl) { |
{ | ||
"name": "googlemapsutil", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "utility to use google map easily", | ||
@@ -19,3 +19,4 @@ "main": "googlemapsutil.js", | ||
"geocoding", | ||
"reverse" | ||
"reverse", | ||
"static maps" | ||
], | ||
@@ -22,0 +23,0 @@ "directories": { |
@@ -126,2 +126,23 @@ googleMapsUtil | ||
## [Timezone API](https://developers.google.com/maps/documentation/timezone/ "timezone") | ||
- timezone(lat, lng, timestamp, options, cb, sensor, isRequest) | ||
- parameter | ||
- lat: latitude (required) | ||
- lng: longitude (required) | ||
- timestamp: timestamp (required) | ||
- options: optional parameter. | ||
- set key value object | ||
- cb: call back function | ||
- sensor: sensor parameter (default false) | ||
- isRequest: if this value is false, return generated url(not do http request)(default null) | ||
## [Static Maps API]https://developers.google.com/maps/documentation/staticmaps/ "staticmaps") | ||
- staticmap(parameters, cb, sensor, isHttps, isRequest) | ||
- parameter | ||
- parameters: key value parameter | ||
- cb: call back function | ||
- sensor: sensor parameter (default false) | ||
- isHttps: https setting (default false) | ||
- isRequest: if this value is false, return generated url(not do http request)(default null) | ||
## Optional API | ||
@@ -146,2 +167,21 @@ - setProxy | ||
## Optional API | ||
- setProxy | ||
- set proxy for http request | ||
- setProxy(proxy, port); | ||
- proxy: ptocy | ||
- port: port | ||
- setParameter | ||
- set parameter to use each api | ||
- setParameter(key, value); | ||
- This parameter is stored internally and used at every request | ||
- clearParameter | ||
- clear stored parameter | ||
- setOutput | ||
- set output format | ||
- xml or json | ||
## Usage 1 | ||
@@ -148,0 +188,0 @@ // call api |
37130
18
831
292