google-panorama-by-location
Gets a Google StreetView Panorama by [ lat, lng ]
, supports API v3.20-v3.22. Also features some Node support.
var panorama = var location = 5150700703827454 -012791916931155356
In Node, the request uses an undocumented API entry-point, using xhr-request. It only provides { id, latitude, longitude }
. This is mostly useful for unit testing.
Usage
panorama(location, [opt], cb)
Gets the panorama data at the given location
, which is an array of [ latitude, longitude ]
. The opt
object is optional, containing:
radius
- the radius to search, defaults to 50service
- (browser only) the Google APIStreetViewService
to use, defaults to a new instance
In API v3.21+, you can also pass preference
and source
for the StreetViewLocationRequest.
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
.
node
The node.js entry point uses xhr-request to request the JSON, so it works in both Node and the Browser. This means you can require it for demos and quick unit testing in the 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.
See Also
License
MIT, see LICENSE.md for details.