[Commits] r1502 - in sandbox/cmoullet/ux/StreetViewPanel/ux: control widgets
commits at geoext.org
commits at geoext.org
Thu Nov 26 11:52:20 CET 2009
Author: cmoullet
Date: 2009-11-26 11:52:20 +0100 (Thu, 26 Nov 2009)
New Revision: 1502
Modified:
sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js
sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
Log:
Rearchitecture code
Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js 2009-11-26 07:03:03 UTC (rev 1501)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/control/Click.js 2009-11-26 10:52:20 UTC (rev 1502)
@@ -36,20 +36,6 @@
lonlat.transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
var clickedPosition = new GLatLng(lonlat.lat, lonlat.lon);
- // Navigation tool
- this.drawNavigationTool = function(layer, position, yaw, links) {
- layer.destroyFeatures();
- var circlePosition = new OpenLayers.Geometry.Point(position.lng(), position.lat());
- circlePosition.transform(new OpenLayers.Projection("EPSG:4326"), this.map.getProjectionObject());
- this.panorama.navigationToolStyle = {
- externalGraphic: "../resources/tool.png",
- pointRadius: 30,
- rotation: this.yaw
- };
- this.panorama.navigationTool = new OpenLayers.Feature.Vector(circlePosition, null, this.panorama.navigationToolStyle);
- // Draw the yaw direction
- layer.addFeatures([this.panorama.navigationTool]);
- };
var callback = function (data) {
if (data) {
if (data.code == 600) {
@@ -60,22 +46,14 @@
var POV = {yaw: this.yaw, pitch: this.pitch, zoom: this.zoom};
this.panorama.setLocationAndPOV(data.location.latlng, POV);
// Add the navigation tool
- this.drawNavigationTool(this.navigationToolLayer, data.location.latlng, this.yaw, data.links)
+ this.panorama.drawNavigationTool(this.panorama, this.panorama.navigationToolLayer, data.location.latlng, this.yaw, data.links)
} else {
alert(OpenLayers.i18n('Google Street View: Unexpected problem'));
}
}
};
- GEvent.addListener(this.panorama, "yawchanged", function(yaw) {
- this.navigationToolStyle.rotation = yaw;
- this.navigationTool.layer.drawFeature(this.navigationTool);
- });
- GEvent.addListener(this.panorama, "flashresponse", function(yaw) {
- //TODO move the 2Dtool
- });
this.streetviewclient.getNearestPanorama(clickedPosition, callback.createDelegate(this));
-
},
onDblclick: function(evt) {
Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js 2009-11-26 07:03:03 UTC (rev 1501)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js 2009-11-26 10:52:20 UTC (rev 1502)
@@ -59,7 +59,7 @@
yaw: 180,
/** api: config[pitch]
- * ``Number`` The camera pitch in degrees, relative to the street view vehicle. Ranges from 90 degrees (directly upwards) to -90 degrees (directly downwards).
+ * ``Number`` The camera pitch in degrees, relative to the street view vehicle. Ranges from 90 degrees (directly upwards) to -90 degrees (directly downwards).
*/
/** private: property[180]
* ``Number`` Camery pitch
@@ -95,12 +95,34 @@
GeoExt.ux.StreetViewPanel.superclass.afterRender.call(this);
this.panorama = new GStreetviewPanorama(this.body.dom);
+
+ // Navigation tool associated to panorama
+ this.panorama.map = this.map;
+ this.panorama.drawNavigationTool = function(panorama, layer, position, yaw, links) {
+ layer.destroyFeatures();
+ var circlePosition = new OpenLayers.Geometry.Point(position.lng(), position.lat());
+ circlePosition.transform(new OpenLayers.Projection("EPSG:4326"), panorama.map.getProjectionObject());
+ panorama.navigationToolStyle = {
+ externalGraphic: "../resources/tool.png",
+ pointRadius: 30,
+ rotation: panorama.getPOV().yaw
+ };
+ panorama.navigationTool = new OpenLayers.Feature.Vector(circlePosition, null, panorama.navigationToolStyle);
+ layer.addFeatures([panorama.navigationTool]);
+ };
+
+ // Add event handler for panorama
+ GEvent.addListener(this.panorama, "yawchanged", function(yaw) {
+ this.navigationToolStyle.rotation = yaw;
+ this.navigationTool.layer.drawFeature(this.navigationTool);
+ });
+
this.streetviewclient = new GStreetviewClient();
if (this.map) {
if (this.clickMode) {
if (this.showTool) {
- this.navigationToolLayer = new OpenLayers.Layer.Vector("2DNavigationTool");
- this.map.addLayer(this.navigationToolLayer);
+ this.panorama.navigationToolLayer = new OpenLayers.Layer.Vector("2DNavigationTool");
+ this.map.addLayer(this.panorama.navigationToolLayer);
}
this.clickControl = new GeoExt.ux.Click({
handlerOptions: {
@@ -110,8 +132,7 @@
streetviewclient: this.streetviewclient,
yaw: this.yaw,
pitch: this.pitch,
- level: this.level,
- navigationToolLayer: this.navigationToolLayer
+ level: this.level
});
this.map.addControl(this.clickControl);
this.clickControl.activate();
More information about the Commits
mailing list