google-panorama-by-id
Gets a Google Street View by pano ID. Also features some Node support.
var panorama = var id = 'dXZfBMex9_L7jO2JW3FTdA'
In Node, the request uses an undocumented API entry-point, using request. It only provides { id, latitude, longitude }
. This is mostly useful for unit testing.
Usage
panorama(id, [opt], cb)
Gets the panorama data at the given id
, a pano_id string like "dXZfBMex9_L7jO2JW3FTdA"
. The opt
object is optional, and can contain:
service
- (browser only) the Google APIStreetViewService
to use, defaults to a new instance
The Node-style callback uses the form (err, result)
, where err
will be null if a street view was found. On success, result
is an object containing:
id: String // pano ID latitude: Number longitude: Number
In the browser, the result
object will also contain other details from StreetViewService
, like copyright
and location
.
node
The node.js entry point uses request to request the JSON. However, it also works in the browser, using jsonp. This means you can require it for quick unit testing in Node/browser, without bringing in the entire Google Client library.
var panorama =
However, this is not recommended for production, since it uses an undocumented API entry point and only returns a limited set of data.
See Also
License
MIT, see LICENSE.md for details.