Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/sugendran/node-googlemaps i…
Browse files Browse the repository at this point in the history
…nto develop
  • Loading branch information
moshen committed Sep 16, 2011
2 parents f7ce773 + 998a570 commit 2790c2f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/googlemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ exports.places = function(latlng, radius, key, callback, sensor, types, lang, na
makeRequest(path, true, returnObjectFromJSON(callback));
}

exports.placeDetails = function(referenceId, key, callback, sensor, lang) {
var args = {
reference: referenceId,
key: key
}
if (lang) args.lang = lang;
args.sensor = sensor || 'false';

var path = '/maps/api/place/details/json?' + qs.stringify(args);
makeRequest(path, true, returnObjectFromJSON(callback));
}

// http://code.google.com/apis/maps/documentation/geocoding/
exports.geocode = function(address , callback , sensor , bounds , region , language){
var args = {
Expand Down Expand Up @@ -154,12 +166,14 @@ var makeRequest = function(path, secure, callback){

protocol.get(options, function (res) {
var data = "";
var httpEnd = function(){
if (res.statusCode == 200) callback(null, data);
else callback(new Error("Response status code: " + res.statusCode), data);
};
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function () {
if (res.statusCode == 200) callback(null, data);
else callback(new Error("Response status code: " + res.statusCode), data);
});
res.on('end', httpEnd);
res.on('close', httpEnd);
}).on('error', function (err) { callback(err); });
}

0 comments on commit 2790c2f

Please sign in to comment.