Giter Club home page Giter Club logo

google-panorama-by-location's Introduction

google-panorama-by-location

experimental

Gets a Google StreetView Panorama by [ lat, lng ], supports API v3.20-v3.22. Also features some Node support.

var panorama = require('google-panorama-by-location')

var location = [ 51.50700703827454, -0.12791916931155356 ]
panorama(location, function (err, result) {
  if (err) throw err
  
  // pano ID
  console.log(result.id)

  // actual latitude, longitude
  console.log(result.latitude)
  console.log(result.longitude)

  // other details from Google API
  console.log(result.copyright)
})

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

NPM

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 50
  • service - (browser only) the Google API StreetViewService 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 = require('google-panorama-by-location/node')

panorama([ lat, lng ], callback)

However, this is not recommended for production, since it uses an undocumented API entry point.

See Also

License

MIT, see LICENSE.md for details.

google-panorama-by-location's People

Contributors

mattdesl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-panorama-by-location's Issues

Cannot read property 'id' of undefined

When I put the code in a for loop (500 iterations and more) to grab many IDs I get this error. What do you think this has to do with? It works for like 400 iterations only.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.