Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
google-locations
Advanced tools
Google Places API for Node.js, with convenience methods to search by address or phone number
Google Places + Google Geocoding API module for node.js. Supports basic functions on the Google Places API -- search, autocomplete, and details -- as well as geocoding and reverse geocoding capabilities with the Google Geocoding API. It also contains two convenience methods, searchByAddress and searchByPhone, that allow users to retrieve Place details by address or phone number.
This module requires a valid Google API key and enabled access for Google Places and/or Google Geocoding. Check out the Google Places API docs or Google Geocoding API docs for more information. Please note that searchByAddress uses the Geocoding API and searchByPhone uses the /place/textsearch endpoint which counts as 10 requests toward your daily quota.
This is a fork of the node-google-places module which appears to no longer be actively maintained. Please feel free to submit pull requests for features and additional test coverage!
npm install google-locations
This method makes requests to the /place/nearbysearch endpoint. Any supported query parameter/value for that endpoint is a valid key/value for the options object.
This method makes requests to the /place/autocomplete endpoint. Any supported query parameter/value for that endpoint is a valid key/value for the options object.
This method makes requests to the /place/details endpoint. It requires a placeid parameter, but any supported query parameter/value for that endpoint is a valid key/value for the options object.
This method lets you query for Google Place details by address and location name. It is a convenience wrapper that geocodes an address, does a place search for matching names near that geocoordinate, then does follow-up detail requests for each result in search, up to a specified limit. The only mandatory parameter is address. If rankby is 'distance', name must be specified. If rankby is 'prominence', radius must be specified. If rankby is not specified, it will default to 'distance' and therefore name will be required. The most reliable practice is to specify both an address and name. The number of detail requests is limited by the 'maxResults' parameter: if maxResults isn't specified it will default to 1, but maxResults will automatically never be greater than the number of results returned by a search request.
This method lets you query for Google Place details by phone number. 'phone' is a required parameter. If 'maxResults' isn't specified it will default to 1, only returning details about the top result in search. NOTE: This method uses the Google Places API's /place/textsearch endpoint, so each request counts as 10 requests toward your daily quota!
var GoogleLocations = require('google-locations');
var locations = new GoogleLocations('YOUR_API_KEY');
locations.search({keyword: 'Google', location: [37.42291810, -122.08542120]}, function(err, response) {
console.log("search: ", response.results);
locations.details({placeid: response.results[0].place_id}, function(err, response) {
console.log("search details: ", response.result.name);
// search details: Google
});
});
locations.autocomplete({input: 'Verm', types: "(cities)"}, function(err, response) {
console.log("autocomplete: ", response.predictions);
var success = function(err, response) {
console.log("did you mean: ", response.result.name);
// did you mean: Vermont
// did you mean: Vermont South
// did you mean: Vermilion
// did you mean: Vermillion
};
for(var index in response.predictions) {
locations.details({placeid: response.predictions[index].place_id}, success);
}
});
locations.searchByAddress({address: '1600 Amphitheatre Pkwy, Mountain View, CA', name: 'Goo', maxResults: 2, rankby: "prominence", radius: 5000}, function(err, response){
for (var index in response.details) {
console.log("Potential Match: " + response.details[index].name);
// Potential Match: Google
// Potential Match: Gooey Cookie Factory
}
for (var index in response.errors) {
console.log("Error looking up place details: ", response.errors[index]);
}
});
locations.searchByPhone({phone: "(650) 253-0000"}, maxResults: 2, function(err, response){
// Returns up to 2 matches for this phone number
});
To test simply install development dependencies and run:
vows test/* --spec
FAQs
Google Places API for Node.js, with convenience methods to search by address or phone number
The npm package google-locations receives a total of 259 weekly downloads. As such, google-locations popularity was classified as not popular.
We found that google-locations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.