getNearestSphere

getNearestSphere

Searches for the sphere nearest to a specified latitude and longitude, passes it to the optional callback function (if provided), and returns it.

getNearestPano has been deprecated and replaced with getNearestSphere. This is not a breaking change.

Parameters:

  • lat (number): Latitude for search

  • lng (number): Longitude for search

  • callback (function): (OPTIONAL) A callback function to execute after finding the nearest sphere. It will be passed an object with the the following attributes automatically:

    • distance (number): The distance (in meters) between the location specified by lat and lng and the sphere found, or undefined if no sphere was found

    • sphereId: (number): The id of the sphere found, or undefined if no sphere was found

    • sphereMarker: An object with one value:

      • marker: An embedded object with one value:

        • position: An object with 2 values representing the position of the sphere, or undefined if no sphere was found

          • lat: The latitude of the sphere

          • lng: The longitude of the sphere

Returns: A promise that resolves to the same object that is passed to the callback.

Code Sample