node-geocoder
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -23,3 +23,3 @@ (function() { | ||
}, | ||
_getGeocoder: function(geocoderName, adapter) { | ||
_getGeocoder: function(geocoderName, adapter, extra) { | ||
if (geocoderName === 'google') { | ||
@@ -45,2 +45,7 @@ var GoogleGeocoder = new require('./geocoder/googlegeocoder.js'); | ||
} | ||
if (geocoderName === 'mapquest') { | ||
var MapQuestGeocoder = new require('./geocoder/mapquestgeocoder.js'); | ||
return new MapQuestGeocoder(adapter, extra.apiKey); | ||
} | ||
}, | ||
@@ -54,3 +59,3 @@ _getFormatter: function(formatterName) { | ||
}, | ||
getGeocoder: function(geocoderAdapter, httpAdapter, formatter) { | ||
getGeocoder: function(geocoderAdapter, httpAdapter, extra) { | ||
@@ -61,2 +66,6 @@ if (!httpAdapter || httpAdapter === 'undefined') { | ||
if (!extra || extra == 'undefinded') { | ||
extra = {}; | ||
} | ||
if (Helper.isString(httpAdapter)) { | ||
@@ -67,5 +76,7 @@ httpAdapter = this._getHttpAdapter(httpAdapter); | ||
if (Helper.isString(geocoderAdapter)) { | ||
geocoderAdapter = this._getGeocoder(geocoderAdapter, httpAdapter); | ||
geocoderAdapter = this._getGeocoder(geocoderAdapter, httpAdapter, extra); | ||
} | ||
formatter = extra.formatter; | ||
if (Helper.isString(formatter)) { | ||
@@ -72,0 +83,0 @@ formatter = this._getFormatter(formatter); |
{ | ||
"name": "node-geocoder", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "node geocoding library", | ||
@@ -5,0 +5,0 @@ "main": "lib/geocoderfactory.js", |
@@ -20,2 +20,3 @@ # node-geocoder | ||
* `openstreetmap` : OpenStreetMapGeocoder support adress geocoding and reverse geocoding | ||
* `mapquest` : MapQuestGeocoder support adress geocoding and reverse geocoding need an apiKey | ||
@@ -35,5 +36,9 @@ ## Http adapter | ||
var httpAdapter = 'http'; | ||
var formatter = null; | ||
// optionnal | ||
var extra = { | ||
apiKey: 'YOUR_API_KEY', | ||
formatter: null | ||
}; | ||
var geocoder = require('node-geocoder').getGeocoder(geocoderProvider, httpAdapter, formatter); | ||
var geocoder = require('node-geocoder').getGeocoder(geocoderProvider, httpAdapter, extra); | ||
@@ -57,4 +62,2 @@ geocoder.geocode('29 champs elysée paris', function(err, res) { | ||
## More | ||
@@ -61,0 +64,0 @@ |
10
test.js
@@ -7,3 +7,3 @@ var GoogleAdapter = require ('./lib/geocoder/googlegeocoder.js'); | ||
var adapter = GeocoderFactory.getGeocoder('google', 'http', 'gpx'); | ||
var adapter = GeocoderFactory.getGeocoder('mapquest', 'http', {apiKey: 'Fmjtd%7Cluubn962n5%2C2x%3Do5-907xgz'}); | ||
@@ -16,6 +16,6 @@ //var adapter = new GoogleAdapter(new RequestifyAdapter()); | ||
}); | ||
adapter.geocode('29 rue chevreul lyon', function(err, res) { | ||
console.log(err); | ||
console.log(res); | ||
}); | ||
// adapter.geocode('29 rue chevreul lyon FR', function(err, res) { | ||
// console.log(err); | ||
// console.log(res); | ||
// }); | ||
@@ -22,0 +22,0 @@ setTimeout(function() { |
@@ -30,3 +30,3 @@ (function() { | ||
it('called with "google" and "http" and "gpx" must return google geocoder with http adapter and gpx formatter', function() { | ||
var geocoder = GeocoderFactory.getGeocoder('google', 'http', 'gpx'); | ||
var geocoder = GeocoderFactory.getGeocoder('google', 'http', { formatter : 'gpx'}); | ||
@@ -33,0 +33,0 @@ var geocoderAdapter = geocoder._geocoder; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45847
27
990
81
8
7