Street View Service
Гугл карты нью йорк панорама
You may wish to programmatically determine the availability of Street View data, or return information about particular panoramas, without requiring direct manipulation of a map/panorama. You may do so using the StreetViewService object, which provides an interface to the data stored in Google’s Street View service.
Street View Service Requests
Accessing the Street View service is asynchronous, since the Google Maps API needs to make a call to an external server. For that reason, you need to pass a callback method to execute upon completion of the request. This callback method processes the result.
You can initiate requests to the StreetViewService using StreetViewPanoRequest or StreetViewLocationRequest .
A request using StreetViewPanoRequest returns panorama data given a reference ID which uniquely identifies the panorama. Note that these reference IDs are only stable for the lifetime of the imagery of that panorama.
A request using StreetViewLocationRequest searches for panorama data at a specified location, using the following parameters:
- location specifies the location (latitude and longitude) to search for a panorama.
- preference sets a preference for which panorama should be found within the radius: the one nearest to the provided location, or the best one within the radius.
- radius sets a radius, specified in meters, in which to search for a panorama, centered on the given latitude and longitude. Defaults to 50 when not supplied.
- source specifies the source of panoramas to search. Valid values are:
- default uses the default sources for Street View; searches are not limited to specific sources.
- outdoor limits searches to outdoor collections. Note that outdoor panoramas may not exist for the specified location.
Street View Service Responses
The function getPanorama() needs a callback function to execute upon retrieval of a result from the Street View service. This callback function returns a set of panorama data within a StreetViewPanoramaData object and a StreetViewStatus code denoting the status of the request, in that order.
A StreetViewPanoramaData object specification contains meta-data about a Street View panorama of the following form:
Note that this data object is not a StreetViewPanorama object itself. To create a Street View object using this data, you would need to create a StreetViewPanorama and call setPano() , passing it the ID as noted in the returned location.pano field.
The status code may return one of the following values:
- OK indicates that the service found a matching panorama.
- ZERO_RESULTS indicates that the service could not find a matching panorama with the passed criteria.
- UNKNOWN_ERROR indicates that a Street View request could not be processed, though the exact reason is unknown.
The following code creates a StreetViewService that responds to user clicks on a map by creating markers which, when clicked, display a StreetViewPanorama of that location. The code uses the contents of StreetViewPanoramaData returned from the service.