[Commits] r1545 - in sandbox/cmoullet/ux/GoogleEarthPanel: examples ux ux/control ux/widgets
commits at geoext.org
commits at geoext.org
Thu Dec 3 21:55:35 CET 2009
Author: cmoullet
Date: 2009-12-03 21:55:35 +0100 (Thu, 03 Dec 2009)
New Revision: 1545
Added:
sandbox/cmoullet/ux/GoogleEarthPanel/ux/control/
sandbox/cmoullet/ux/GoogleEarthPanel/ux/control/GoogleEarthClick.js
Modified:
sandbox/cmoullet/ux/GoogleEarthPanel/examples/GoogleEarthPanelExample.html
sandbox/cmoullet/ux/GoogleEarthPanel/ux/widgets/GoogleEarthPanel.js
Log:
Add clickMode, fix permalink issues wit boolean
Modified: sandbox/cmoullet/ux/GoogleEarthPanel/examples/GoogleEarthPanelExample.html
===================================================================
--- sandbox/cmoullet/ux/GoogleEarthPanel/examples/GoogleEarthPanelExample.html 2009-12-03 12:28:55 UTC (rev 1544)
+++ sandbox/cmoullet/ux/GoogleEarthPanel/examples/GoogleEarthPanelExample.html 2009-12-03 20:55:35 UTC (rev 1545)
@@ -9,23 +9,24 @@
<script src='http://maps.google.com/maps?file=api&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA"></script>
-->
- <!-- 192.168.1.44
+ <!-- 192.168.1.44 -->
<script src='http://maps.google.com/maps?file=api&key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRSIMweZSjbRtcUk2F5YNqLnri0MahTrQJRaRPWFP0OUB1b6unv37Jg7vQ'></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRSIMweZSjbRtcUk2F5YNqLnri0MahTrQJRaRPWFP0OUB1b6unv37Jg7vQ"></script>
- -->
+
<!-- 10.27.10.44
<script src='http://maps.google.com/maps?file=api&key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRQg15vMUgV9rqK5U3tGsPdx8x_OsBTeBHQ0wK75MLc8dB7yu0cRx36VJQ'></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRQg15vMUgV9rqK5U3tGsPdx8x_OsBTeBHQ0wK75MLc8dB7yu0cRx36VJQ"></script>
-->
- <!-- Google Maps API for "dev.geoext.org" -->
+ <!-- Google Maps API for "dev.geoext.org"
<script src='http://maps.google.com/maps?file=api&key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA'></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA"></script>
-
+ -->
<script src="http://openlayers.org/api/2.8/OpenLayers.js"></script>
<script type="text/javascript" src="../../../trunk/geoext/lib/GeoExt.js"></script>
<script type="text/javascript" src="../ux/widgets/GoogleEarthPanel.js"></script>
+ <script type="text/javascript" src="../ux/control/GoogleEarthClick.js"></script>
<script type="text/javascript" src="GoogleEarthPanelExample.js"></script>
</head>
Added: sandbox/cmoullet/ux/GoogleEarthPanel/ux/control/GoogleEarthClick.js
===================================================================
--- sandbox/cmoullet/ux/GoogleEarthPanel/ux/control/GoogleEarthClick.js (rev 0)
+++ sandbox/cmoullet/ux/GoogleEarthPanel/ux/control/GoogleEarthClick.js 2009-12-03 20:55:35 UTC (rev 1545)
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+Ext.namespace('GeoExt.ux');
+
+GeoExt.ux.GoogleEarthClick = OpenLayers.Class(OpenLayers.Control, {
+ defaultHandlerOptions: {
+ 'single': true,
+ 'double': false,
+ 'pixelTolerance': 0,
+ 'stopSingle': false,
+ 'stopDouble': false
+ },
+
+ initialize: function(options) {
+ this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
+ OpenLayers.Control.prototype.initialize.apply(this, arguments);
+ this.handler = new OpenLayers.Handler.Click(this, {
+ 'click': this.onClick,
+ 'dblclick': this.onDblclick},
+ this.handlerOptions
+ );
+ },
+
+
+ onClick: function(evt) {
+ var lonlat = this.gePanel.map.getLonLatFromViewPortPx(evt.xy);
+ lonlat.transform(this.gePanel.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
+ this.gePanel.setLookAt(lonlat.lat,
+ lonlat.lon,
+ this.gePanel.altitude,
+ this.gePanel.altitudeMode,
+ this.gePanel.heading,
+ this.gePanel.tilt,
+ this.gePanel.range);
+ },
+
+ onDblclick: function(evt) {
+ alert('doubleClick');
+ }
+
+});
Modified: sandbox/cmoullet/ux/GoogleEarthPanel/ux/widgets/GoogleEarthPanel.js
===================================================================
--- sandbox/cmoullet/ux/GoogleEarthPanel/ux/widgets/GoogleEarthPanel.js 2009-12-03 12:28:55 UTC (rev 1544)
+++ sandbox/cmoullet/ux/GoogleEarthPanel/ux/widgets/GoogleEarthPanel.js 2009-12-03 20:55:35 UTC (rev 1545)
@@ -53,13 +53,13 @@
navigationMode2D: true,
// Move Google Earth when 2D map is moved
- navigationModeFrom2D: true,
+ navigationModeFrom2D: false,
// Check that the targer and camera points are always in the map: not implemented
navigationMode3D: false,
// Click in the map to set the camera point: not implemented
- clickMode: false,
+ clickMode: true,
/** property[earthAvailable]
* Defines if Google Earth is available
@@ -137,15 +137,17 @@
},
setLookAt: function (lat, lon, altitude, altitudeMode, heading, tilt, range) {
- var lookAt = this.ge.createLookAt('');
- lookAt.set(lat,
- lon,
- altitude,
- altitudeMode,
- heading,
- tilt,
- range);
- this.ge.getView().setAbstractView(lookAt);
+ if (this.ge) {
+ var lookAt = this.ge.createLookAt('');
+ lookAt.set(lat,
+ lon,
+ altitude,
+ altitudeMode,
+ heading,
+ tilt,
+ range);
+ this.ge.getView().setAbstractView(lookAt);
+ }
},
// Init Google Earth
@@ -155,7 +157,7 @@
// Set Google Earth Properties
this.ge.getWindow().setVisibility(true);
this.geProperties.geProjection = new OpenLayers.Projection("EPSG:4326");
- this.altitudeMode=this.ge.ALTITUDE_RELATIVE_TO_GROUND;
+ this.altitudeMode = this.ge.ALTITUDE_RELATIVE_TO_GROUND;
this.setLookAt(this.lookAt.lat,
this.lookAt.lon,
this.altitude,
@@ -217,6 +219,17 @@
this.drag.activate();
}
+ if (this.map && this.clickMode) {
+ this.clickControl = new GeoExt.ux.GoogleEarthClick({
+ handlerOptions: {
+ "single": true
+ },
+ gePanel: this
+ });
+ this.map.addControl(this.clickControl);
+ this.clickControl.activate();
+ }
+
// Refreshes GE on map move
if (this.map && this.navigationModeFrom2D) {
this.map.events.on({
@@ -293,7 +306,7 @@
} else {
permalink = '';
}
- var lookAt = this.ge.getView().copyAsLookAt(this.ge.ALTITUDE_RELATIVE_TO_GROUND);
+ var lookAt = this.ge.getView().copyAsLookAt(this.altitudeMode);
permalink = permalink + "lookAtLatitude=" + lookAt.getLatitude();
permalink = permalink + "&lookAtLongitude=" + lookAt.getLongitude();
@@ -348,48 +361,58 @@
this.range = parseFloat(parameters.range);
}
if (parameters.altitudeMode) {
- this.altitudeMode = parameters.altitudeMode;
+ this.altitudeMode = parseInt(parameters.altitudeMode, 10);
}
if (parameters.showBordersLayer) {
- this.showBordersLayer = parameters.showBordersLayer;
+ this.showBordersLayer = this.stringToBoolean(parameters.showBordersLayer);
}
if (parameters.showTerrainLayer) {
- this.showTerrainLayer = parameters.showTerrainLayer;
+ this.showTerrainLayer = this.stringToBoolean(parameters.showTerrainLayer);
}
if (parameters.showRoadsLayer) {
- this.showRoadsLayer = parameters.showRoadsLayer;
+ this.showRoadsLayer = this.stringToBoolean(parameters.showRoadsLayer);
}
if (parameters.showBuildingsLayer) {
- this.showBuildingsLayer = parameters.showBuildingsLayer;
+ this.showBuildingsLayer = this.stringToBoolean(parameters.showBuildingsLayer);
}
if (parameters.showBuildingsLowResolutionLayer) {
- this.showBuildingsLowResolutionLayer = parameters.showBuildingsLowResolutionLayer;
+ this.showBuildingsLowResolutionLayer = this.stringToBoolean(parameters.showBuildingsLowResolutionLayer);
}
if (parameters.navigationMode2D) {
- this.navigationMode2D = parameters.navigationMode2D;
+ this.navigationMode2D = this.stringToBoolean(parameters.navigationMode2D);
}
if (parameters.navigationModeFrom2D) {
- this.navigationModeFrom2D = parameters.navigationModeFrom2D;
+ this.navigationModeFrom2D = this.stringToBoolean(parameters.navigationModeFrom2D);
}
if (parameters.navigationMode3D) {
- this.navigationMode3D = parameters.navigationMode3D;
+ this.navigationMode3D = this.stringToBoolean(parameters.navigationMode3D);
}
if (parameters.clickMode) {
- this.clickMode = parameters.clickMode;
+ this.clickMode = this.stringToBoolean(parameters.clickMode);
}
if (this.ge) {
google.earth.createInstance(this.body.dom, this.initCallback.createDelegate(this), this.failureCallback.createDelegate(this));
} else {
this.setLookAt(this.lookAt.lat,
- this.lookAt.lon,
- this.altitude,
- this.altitudeMode,
- this.heading,
- this.tilt,
- this.range);
+ this.lookAt.lon,
+ this.altitude,
+ this.altitudeMode,
+ this.heading,
+ this.tilt,
+ this.range);
}
},
+ stringToBoolean: function(string) {
+ switch (string.toLowerCase()) {
+ case "true": case "yes": case "1": return true;
+ case "false": case "no": case "0": case null: return false;
+ default: return Boolean(string);
+ }
+ },
+
+
+
beforeDestroy: function() {
//Delete object
if (this.map && this.navigationMode2D) {
@@ -399,6 +422,10 @@
this.earthLayer.destroy();
this.features = null;
}
+ if (this.map && this.clickMode) {
+ this.clickControl.deactivate();
+ this.map.removeControl(this.clickControl);
+ }
if (this.map && this.navigationModeFrom2D) {
this.map.events.un({
move: this.onMoveEnd,
@@ -424,6 +451,12 @@
* Changes camera and lookAt points on GE move
*/
onFrameEnd: function() {
+ var lookAt = this.ge.getView().copyAsLookAt(this.altitudeMode);
+ this.range = lookAt.getRange();
+ this.til = lookAt.getTilt();
+ this.heading = lookAt.getHeading();
+ this.altitude = lookAt.getAltitude();
+ this.altitudeMode = lookAt.getAltitudeMode();
if (this.map && this.navigationMode2D) {
this.refreshMap();
}
@@ -440,7 +473,7 @@
this.transformToGE(lonLat);
- var lookAt = this.ge.getView().copyAsLookAt(this.ge.ALTITUDE_RELATIVE_TO_GROUND);
+ var lookAt = this.ge.getView().copyAsLookAt(this.altitudeMode);
lookAt.setLongitude(lonLat.lon);
lookAt.setLatitude(lonLat.lat);
this.ge.getView().setAbstractView(lookAt);
@@ -456,7 +489,7 @@
}
// Gets current lookAt position
- var lookAt = this.ge.getView().copyAsLookAt(this.ge.ALTITUDE_RELATIVE_TO_GROUND);
+ var lookAt = this.ge.getView().copyAsLookAt(this.altitudeMode);
var geLonLat = new OpenLayers.LonLat(lookAt.getLongitude(),
lookAt.getLatitude());
@@ -491,10 +524,10 @@
}
// Gets current camera ans lookAt positions
- var lookAt = this.ge.getView().copyAsLookAt(this.ge.ALTITUDE_RELATIVE_TO_GROUND);
+ var lookAt = this.ge.getView().copyAsLookAt(this.altitudeMode);
var pl = new OpenLayers.LonLat(lookAt.getLongitude(), lookAt.getLatitude());
this.transformFromGE(pl);
- var camera = this.ge.getView().copyAsCamera(this.ge.ALTITUDE_RELATIVE_TO_GROUND);
+ var camera = this.ge.getView().copyAsCamera(this.altitudeMode);
var pc = new OpenLayers.LonLat(camera.getLongitude(), camera.getLatitude());
this.transformFromGE(pc);
More information about the Commits
mailing list