[Commits] r1509 - sandbox/cmoullet/ux/StreetViewPanel/ux/widgets
commits at geoext.org
commits at geoext.org
Sat Nov 28 08:00:02 CET 2009
Author: cmoullet
Date: 2009-11-28 08:00:02 +0100 (Sat, 28 Nov 2009)
New Revision: 1509
Modified:
sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
Log:
Finalize interction between map and panorama
Modified: sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js
===================================================================
--- sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js 2009-11-28 00:13:46 UTC (rev 1508)
+++ sandbox/cmoullet/ux/StreetViewPanel/ux/widgets/StreetViewPanel.js 2009-11-28 07:00:02 UTC (rev 1509)
@@ -131,16 +131,8 @@
// Compute the new position
var circlePosition = new OpenLayers.Geometry.Point(position.lng(), position.lat());
circlePosition.transform(new OpenLayers.Projection("EPSG:4326"), panorama.map.getProjectionObject());
- // Define a style
- panorama.navigationToolStyle = {
- externalGraphic: "../resources/tool.png",
- graphicHeight: 32,
- graphicWidth: 32,
- pointRadius: 32,
- rotation: panorama.yaw
- };
// Add a vector feature in navigation layer
- panorama.navigationTool = new OpenLayers.Feature.Vector(circlePosition, null, panorama.navigationToolStyle);
+ panorama.navigationTool = new OpenLayers.Feature.Vector(circlePosition, {yaw: panorama.yaw});
panorama.navigationToolLayer.addFeatures([panorama.navigationTool]);
};
@@ -166,7 +158,7 @@
GEvent.addListener(this.panorama, "yawchanged", function(yaw) {
// This is the panorama
if (this.showTool) {
- this.navigationToolStyle.rotation = yaw;
+ this.navigationTool.attributes.yaw = yaw;
this.navigationTool.layer.drawFeature(this.navigationTool);
}
this.yaw = yaw;
@@ -174,7 +166,11 @@
GEvent.addListener(this.panorama, "zoomchanged", function(zoom) {
this.zoom = zoom;
});
+ GEvent.addListener(this.panorama, "initialized", function(gstreetviewlocation) {
+ this.streetviewclient.getPanoramaById(gstreetviewlocation.panoId, this.callbackDrawTools.createDelegate(this));
+ });
+
// Callback to manage panorama when used with getNearestPanorama
this.panorama.callback = function (data) {
this.deleteFeatures = function() {
@@ -218,6 +214,47 @@
}
};
+ // Callback to manage panorama when used with getNearestPanorama
+ this.panorama.callbackDrawTools = function (data) {
+ this.deleteFeatures = function() {
+ if (this.showTool) {
+ if (this.map) {
+ this.navigationToolLayer.destroyFeatures();
+ }
+ }
+ if (this.showLinks) {
+ if (this.map) {
+ this.navigationLinkLayer.destroyFeatures();
+ }
+ }
+ };
+ if (data) {
+ if (data.code == 600) {
+ this.deleteFeatures();
+ alert(OpenLayers.i18n('Google Street View: No panorama found near this position. You have to click elsewhere ;-)'));
+ } else if (data.code == 500) {
+ this.deleteFeatures()
+ alert(OpenLayers.i18n('Google Street View: Server error'));
+ } else if (data.code == 200) {
+ // Add the navigation tool
+ if (this.showTool) {
+ if (this.map) {
+ this.drawNavigationTool(this, data.location.latlng);
+ }
+ }
+ // Add the links
+ if (this.panorama.showLinks) {
+ if (this.map) {
+ this.drawLinkTool(this, data.location.latlng, data.links);
+ }
+ }
+ } else {
+ this.deleteFeatures();
+ alert(OpenLayers.i18n('Google Street View: Unexpected problem'));
+ }
+ }
+ };
+
// Set initial position of panorama
if (this.panoramaLocation) {
this.streetviewclient.getNearestPanorama(this.panoramaLocation, this.callback.createDelegate(this));
@@ -241,14 +278,12 @@
this.panorama.navigationToolLayer = new OpenLayers.Layer.Vector("2DNavigationTool", {
styleMap: new OpenLayers.StyleMap({
"default": {
- externalGraphic: "../resources/link.png",
- graphicHeight: 16,
- graphicYOffset: -26,
- rotation: "${angle}"
+ externalGraphic: "../resources/tool.png",
+ graphicHeight: 40,
+ rotation: "${yaw}"
},
"select": {
- cursor: "pointer",
- externalGraphic: "../resources/link_selected.png"
+ cursor: "pointer"
}
})});
this.map.addLayer(this.panorama.navigationToolLayer);
@@ -274,8 +309,8 @@
styleMap: new OpenLayers.StyleMap({
"default": {
externalGraphic: "../resources/link.png",
- graphicHeight: 16,
- graphicYOffset: -26,
+ graphicHeight: 24,
+ graphicYOffset: -44,
rotation: "${angle}"
},
"select": {
@@ -290,6 +325,7 @@
clickFeature: function(feature) {
this.streetviewclient.getPanoramaById(feature.attributes.panoId, this.panorama.callback.createDelegate(this));
},
+ allowSelection: true,
panorama: this.panorama,
streetviewclient: this.streetviewclient
});
More information about the Commits
mailing list