[Commits] r1512 - sandbox/cmoullet/ux/StreetViewPanel/ux/widgets
commits at geoext.org
commits at geoext.org
Sat Nov 28 22:12:01 CET 2009
Author: cmoullet
Date: 2009-11-28 22:12:00 +0100 (Sat, 28 Nov 2009)
New Revision: 1512
Modified:
sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
Log:
Add video mode !
Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js 2009-11-28 19:00:31 UTC (rev 1511)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js 2009-11-28 21:12:00 UTC (rev 1512)
@@ -41,6 +41,14 @@
*/
clickMode: true,
+ /** api: config[videoMode]
+ * ``Boolean`` Defines if the video mode is activated.
+ */
+ /** private: property[videoMode]
+ * ``Boolean`` videoMode
+ */
+ videoMode: true,
+
/** api: config[showTool]
* ``Boolean`` Defines if the 2D tool is shown in the map
*/
@@ -122,7 +130,9 @@
this.panorama.showTool = this.showTool;
this.panorama.showLinks = this.showLinks;
this.panorama.clickMode = this.clickMode;
+ this.panorama.videoMode = this.videoMode;
this.panorama.streetviewclient = this.streetviewclient;
+ this.panorama.videoPlay = false;
// Draw navigation tool in map
this.panorama.drawNavigationTool = function(panorama, position) {
@@ -206,6 +216,28 @@
if (this.panorama.map) {
this.panorama.drawLinkTool(this.panorama, data.location.latlng, data.links);
}
+ if (this.panorama.videoMode) {
+ this.panorama.previousDifferenceVideo = 361;
+ if (this.panorama.navigationLinks.length > 0 && this.panorama.previousYawVideo) {
+ for (var i = 0; i < this.panorama.navigationLinks.length; i++) {
+ var difference = this.panorama.navigationLinks[i].attributes.angle - this.panorama.previousYawVideo;
+ if (difference < -180) {
+ difference = difference + 360;
+ }
+ if (difference > 180) {
+ difference = difference - 360;
+ }
+ if (Math.abs(difference) < this.panorama.previousDifferenceVideo) {
+ this.panorama.previousDifferenceVideo = Math.abs(difference);
+ this.panorama.nextFeature = this.panorama.navigationLinks[i];
+ }
+ }
+ //console.log("callback: previousDifferenceVideo" + this.panorama.previousDifferenceVideo)
+ //console.log("callback: nextYaw: "+ this.panorama.nextFeature.attributes.angle);
+ } else {
+ clearInterval(this.panorama.videoInterval);
+ }
+ }
}
} else {
this.deleteFeatures();
@@ -214,7 +246,7 @@
}
};
- // Callback to manage panorama when used with getNearestPanorama
+ // Callback to manage panorama when used with getPanoramaById
this.panorama.callbackDrawTools = function (data) {
this.deleteFeatures = function() {
if (this.showTool) {
@@ -323,7 +355,33 @@
this.selectControl = new OpenLayers.Control.SelectFeature(this.panorama.navigationLinkLayer, {
hover: true,
clickFeature: function(feature) {
- this.streetviewclient.getPanoramaById(feature.attributes.panoId, this.panorama.callback.createDelegate(this));
+ if (this.panorama.videoMode) {
+ // Play the panorama in video mode
+ this.playVideo = function() {
+ this.panorama.previousYawVideo = feature.attributes.angle;
+
+ if (this.panorama.nextFeature) {
+ feature = this.panorama.nextFeature;
+ this.panorama.previousYawVideo = feature.attributes.angle;
+ }
+ //console.log("PlayVideo: previousYawVideo: "+ this.panorama.previousYawVideo);
+ this.streetviewclient.getPanoramaById(feature.attributes.panoId, this.panorama.callback.createDelegate(this));
+ }
+ // Manage the start and stop of the video
+ if (!this.panorama.videoPlay) {
+ //console.log("Start Play Video");
+ this.panorama.videoInterval = setInterval(this.playVideo.createDelegate(this), 3000);
+ this.playVideo();
+ this.panorama.videoPlay = true;
+ } else {
+ //console.log("Stop Play Video");
+ this.panorama.videoPlay = false;
+ this.panorama.nextFeature = null;
+ clearInterval(this.panorama.videoInterval);
+ }
+ } else {
+ this.streetviewclient.getPanoramaById(feature.attributes.panoId, this.panorama.callback.createDelegate(this));
+ }
},
allowSelection: true,
panorama: this.panorama,
@@ -355,7 +413,7 @@
this.selectControl.deactivate();
this.map.removeControl(this.selectControl);
this.map.removeLayer(this.panorama.navigationLinkLayer);
- this.panorama.navigationLinkLayer.destroy();
+ this.panorama.navigationLinkLayer.destroy();
}
}
this.panorama.remove();
More information about the Commits
mailing list