This class extends BaseClass.
Google Street View provides panoramic 360 degree views from designated roads throughout its coverage area. Street View's API coverage is the same as that for the Google Maps application (https://maps.google.com/). The list of currently supported cities for Street View is available at the Google Maps website.
You can create a panorama view using plugin.google.maps.StreetView.getPanorama(div)
.
<div class="pano" id="pano_canvas1"></div>
var div = document.getElementById("pano_canvas1");
var panorama = plugin.google.maps.StreetView.getPanorama(div);
panorama.setPosition({
target: {lat: 42.345573, lng: -71.098326}
});
Google takes panorama photos with special camera device on moving. Not only special car, but also they uses Trekker, Trolly, Bike, Snow mobile,... etc.
Since they takes panorama photos on moving periodically, there is no panorama photo between two locations that are taken photos.
For this reason, you can specify camera location, but the native API snaps to nearest available camera location.
The PANORAMA_LOCATION_CHANGE
event gives the information where the location is.
var panorama = plugin.google.maps.StreetView.getPanorama(div);
panorama.setPosition({
target: {lat: 42.345573, lng: -71.098326}
});
panorama.on(plugin.google.maps.event.PANORAMA_LOCATION_CHANGE, function(location) {
var panoId = location.panoId; // unique location id
var position = location.latLng; // lat,lng pair
var links = location.links; // links to the next available locations.
// The same as white arrow in panorama.
});
Panorama id (panoId) is unique identify for each panorama location.
This panoId is able to use for Street View Service and Google StreetView Image API.
As described in The PANORAMA_LOCATION_CHANGE
event section, the Google Maps native API searches the nearest location in 50 meters from you requested. This is mostly fine, but this might display unexpected panorama if you want to display particular location. Because Google updates panorama photos every once in a while.
Using panoId avoids this trouble. Since the panoId is bounded to a particular panorama photo (location), you can always display exactly what you want.
panorama.setPosition({
'target': 'FEpIJhSgQJOQCL3wOzoAAA'
})
Note that the above is dummy id.
However, this panoId is NOT permanent Id. If Google updates new panorama photos, new panorama id is generated, and older id is no longer available.
StreetView.getPanorama() | Create a panorama view. |
---|
setPosition() | Sets the current LatLng position for the Street View panorama. |
---|---|
setPov() | Sets the point of view for the Street View panorama. |
setVisible() | Change visibility of the Street View panorama. |
getVisible() | Returns true if the panorama is visible. |
setPanningGesturesEnabled() | Determines whether the user will be able to re-orient the camera by dragging. |
getPanningGesturesEnabled() | Returns true if the panning gesture is enable. |
setZoomGesturesEnabled() | Determines whether the user will be able to pinch to zoom. |
getZoomGesturesEnabled() | Returns true if the zoom gesture is enable. |
setNavigationEnabled() | Determines whether the user will be able to move to a different panorama. Users can use a single tap on navigation links, or double tap the view, to move to a new panorama. |
getNavigationEnabled() | Returns true if the navigation link is enable. |
setStreetNamesEnabled() | Determines whether the user is able to see street names displayed on the ground. |
getStreetNamesEnabled() | Returns true if the street name label is enable. |
getLocation() | Return the last panorama location. |
getPosition() | Return position of the last panorama location. |
getLinks() | Return links of the last panorama location. |
getPanoId() | Return panoId of the last panorama location. |
remove() | Remove the panorama view. |
PANORAMA_LOCATION_CHANGE | Arguments: PanoramaLocation This event is fired when StreetView panorama is moved. |
---|---|
PANORAMA_CAMERA_CHANGE | Arguments: PanoramaCamera This event is fired when panorama is moved, such as panning gesture. |
PANORAMA_CLICK | Arguments: PanoramaClickInfo This event is fired when you click on panorama. |