Below is a small example to get you started. For a more in depth example, go to : https://www.cyclomedia.com
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.0/react.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.0/react-dom.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.17.1/ol.js"></script>
<script type="text/javascript" src="http://streetsmart.cyclomedia.com/api/v16.1/Aperture.js"></script>
<script type="text/javascript" src="http://streetsmart.cyclomedia.com/api/v16.1/StreetSmartApi.js"></script>
<script>
// Here you can now call StreetSmartApi.init(), StreetSmartApi.addPanoramaViewer(),
// or use event contents like this: StreetSmartApi.Events.panoramaViewer.RECORDING_LOADED
</script>
All StreetSmartApi React components must be rendered within this component.
Extends React.Component
React Example:
// In your react components render function
render() {
return (
<Api>
{
// ...add all your Street Smart Components in here
}
</Api>
);
}
Javascript Example:
//Not Applicable, you must use StreetSmartApi.addPanoramaViewer()
PanoramaViewer React Component.
Extends React.Component
React Example:
// In your react components render function
render() {
// notice that to get the proper instance, you need to use the prop "viewerRef" instead of "ref"
return (
<Api>
<PanoramaViewer viewerRef={(instance) => this.panoramaViewer = instance} />
</Api>
);
}
Javascript Example:
//Not applicable, You must use StreetSmartApi.addPanoramaViewer().
Component's Props (for React)
Gets the current active recording of the PanoramaViewer.
(null | CM.aperture.Recording)
Returns whether the timetravel component is visible or hidden
Boolean
Sets the orientation of the PanoramaViewer to look at a certain coordinate.
(Coordinate)
coordinate to look at
([string])
If provided, will use to convert coordinate to viewer srs.
Method to add an event listener.
(string)
Remove an event listener to. E.g. RECORDING_CLICK
(Function)
Function which was set on the event listener.
PanoramaViewer
: Returns back the instance of PanoramaViewer so you can remove events in a chain.
Method to add an event listener.
(string)
Type of event to listen to. E.g. RECORDING_CLICK
(Function)
Callback for event listener. Will provide an event as the first argument.
PanoramaViewer
: Returns back the instance of PanoramaViewer so you can add events in a chain.
Opens a panorama closest to the given address.
(string)
Address you want to search.
([string])
Optional, coordinate system in which the panorama will be opened. E.g. "EPSG:28992" return
Promise<(CM.aperture.Recording | Error)>
: Returns a new promise for the result that may be used to chain additional functions.
Open a panorama near Cyclomedia HQ
//Having StreetSmartApi intialized:
let viewer = streetSmartApi.addPanoramaViewer(viewerDomElement);
// Now open the address]
viewer.openByAddress("Van Voordenpark 1B, Zaltbommel", "EPSG:29882").catch(function(err){ console.log(err.message)});
Opens an image by coordinates and accompanying coordinate system.
(Coordinate)
Coordinate of location to open a panorama
([string])
If provided, will use to convert coordinate to viewer srs.
Promise<(CM.aperture.Recording | Error)>
: Returns a new promise for the result that may be used to chain additional functions.
Opens an image by imageId.
(string)
ID of the image that needs to be opened. E.g. "5D38RPNF".
([string])
Optional, coordinate system in which the panorama will be opened. E.g. "EPSG:28992".
Promise<(CM.aperture.Recording | Error)>
: Returns a new promise for the result that may be used to chain additional functions.
Rotates the panorama vertically by a certain amount, as if the camera is turning to the ground.
(number)
amount to rotate the image, in degrees.
Rotates the panorama horizontally by a certain amount, as if the camera is turning to the left.
(number)
amount to rotate the image, in degrees.
Rotates the panorama horizontally by a certain amount, as if the camera is turning to the right.
(number)
amount to rotate the image, in degrees.
Rotates the panorama vertically by a certain amount, as if the camera is turning to the sky.
(number)
amount to rotate the image, in degrees.
Sets the orientation {yaw, pitch, hFov} of the PanoramaViewer to specific values all at once.
Toggles the visibility of the recording features in the PanoramaViewer.
([Boolean])
if available, sets visibility to this value.
Expands or hides the timetravel components
([Boolean])
if available, -value for expanding or hiding time travel.
Enables or disables timeTravel in the _viewer.
([Boolean])
if available, value for enabling or disablingtoggles time travel.
Zoom in in the Panorama. This will decrease the hFov by 5 degrees.
Zoom out in the Panorama. This will increase the hFov by 5 degrees.
Adds a PanoramaViewer to a specified DOM-element.
(element)
DOM-element the PanoramaViewer gets rendered to.
([Object](default {}))
Options to initialize the panorama viewer with
Name | Description |
---|---|
panoramaViewerOptions.recordingsVisible Boolean
|
If recordings should be visible |
panoramaViewerOptions.timeTravelVisible Boolean
|
If time travel is enabled |
panoramaViewerOptions.navbarVisible Boolean
|
If nav bar is enabled |
PanoramaViewer
: Returns reference to the PanoramaViewer.
Add a panoramaViewer to a DOM element.
<div id="panoramaTarget"/>
// Add a PanoramaViewer to the above div. Set variable as reference.
let panoramaViewer = StreetSmartApi.addPanoramaViewer(document.getElementById('panoramaTarget'), panoramaViewerId);
Destroys panorama viewer
(Any)
instance of the PanoramaViewer you want to destroy.
(Any)
Element of the DOM in which the PanoramaViewer was rendered.
Returns the current 'ready'-state of the API.
Boolean
: 'ready'-state.
Returns the object containing the address search settings.
{locale: (string), database: (string)}
: Object containing the address settings.
Returns the application name of the API.
string
: Application name.
Returns the used version of the API.
string
: API version number.
Returns the object containing functionalities that are currently permitted to use by the user.
Array
: Array containing the permissions.
Initializes the API using the inserted values. Required to use functional PanoramaViewers.
(Object)
Object containing the options used for initializing the API.
Name | Description |
---|---|
options.username [string]
|
Username of the user. |
options.password [string]
|
Password of the user. |
options.tid [string]
|
Password of the user. |
options.apiKey string
|
apiKey given to the user. |
options.srs string
|
Coordinate system used in the API. E.g. "EPSG:29882". |
options.locale [string]
(default 'en-US' )
|
Language used as default in the API. |
options.configurationUrl [string]
|
Alternate configuration url to use for all configuration services |
options.addressSettings [{locale: string, database: string}]
|
The address settings to use for address searches.
locale - The locale to use. e.g. 'nl'. database - The name of the database. e.g. 'CMDatabase'. |
Promise
: Returns a new promise for the result that may be used to chain additional functions.
Initializing a StreetSmartApi.
<script type="text/javascript" src="src/StreetSamrtApi.js"></script>
// Set variables for initialisation.
let options = {
username: "username",
password: "password",
srs: "EPSG:29882",
apiKey: "XXXX-XXXX-XXXX-XXXX",
locale: "en-US",
addressSettings: {
locale: "nl",
database: "CMDatabase"
}
};
// Initalize
StreetSmartApi.init(options).then( successCallback, errorCallback);
Object which contains event type constants for all components.
Names of the events that the PanoramaViewer dispatches.
Triggers when the loaded panorama is altered.
CustomEvent
: event
Triggers when a recording is clicked inside the PanoramaViewer.
CustomEvent
: Returns object, event.detail, which contains the recording clicked and original eventData.
Triggers when one or more tiles could not be loaded.
CustomEvent
: event.detail.request contains the
XMLHttpRequest
which failed.
Triggers when the view (pitch, hFov or yaw) of the panorama is altered.
CustomEvent
: event - Returns obejct, event.detail, which contains the new yaw, pitch and hFov for the viewer.
Triggers when everything that is needed for the view to dislay correctly is loaded.
CustomEvent
: event
Triggers when the view is altered and needs to be (partly) reloaded.
CustomEvent
: event
Coordinate definition
Array of length four with four elements. r, g, b, a, respectively.
Returns all logs, including ones invisible to integrators.
Array<string>
: Array of console logs