Last active
August 19, 2016 20:35
-
-
Save WanderingHogan/7a41d37d4ace03fbc334b1f36c1375f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var viewer = new Cesium.Viewer('cesiumContainer'); | |
| var ellipsoid = viewer.scene.globe.ellipsoid; | |
| //var pos = Cesium.Cartesian3.fromDegrees(-111.0, 40.0, 150000.0); | |
| var lat = 39.2904; | |
| var lng = -76.6; | |
| function loc2wgs() { | |
| return Cesium.Cartesian3.fromDegrees(lng, lat, 150000.0) | |
| } | |
| var entity = viewer.entities.add({ | |
| position: new Cesium.CallbackProperty(function(time, result){ | |
| return loc2wgs(); | |
| }, | |
| false | |
| ), | |
| ellipse : { | |
| semiMinorAxis : 800000.0, | |
| semiMajorAxis : 800000.0, | |
| height: 0, | |
| material : new Cesium.Color(228, 240, 245, .1), | |
| outline : true, | |
| outlineColor : new Cesium.Color(228, 240, 245, .5), | |
| outlineWidth: 5 | |
| } | |
| }); | |
| var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas); | |
| var dragging = false; | |
| handler.setInputAction( | |
| function(click) { | |
| var pickedObject = viewer.scene.pick(click.position); | |
| if (Cesium.defined(pickedObject) && (pickedObject.id === entity)) { | |
| entity.ellipse.scale = 1.2; | |
| dragging = true; | |
| viewer.scene.screenSpaceCameraController.enableRotate = false; | |
| } | |
| }, | |
| Cesium.ScreenSpaceEventType.LEFT_DOWN | |
| ); | |
| handler.setInputAction( | |
| function(movement) { | |
| if (dragging) { | |
| var cartesian = viewer.camera.pickEllipsoid(movement.endPosition); | |
| var cartographic = ellipsoid.cartesianToCartographic(cartesian); | |
| lng = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2); | |
| lat = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2); | |
| //loc2wgs(lat, lng); | |
| entity.position.setCallback(loc2wgs, false) | |
| //pos = Cesium.Cartesian3.fromDegrees(lng, lat, 150000.0); | |
| } | |
| }, | |
| Cesium.ScreenSpaceEventType.MOUSE_MOVE | |
| ); | |
| handler.setInputAction( | |
| function() { | |
| entity.ellipse.scale = 1; | |
| dragging = false; | |
| viewer.scene.screenSpaceCameraController.enableRotate = true; | |
| }, | |
| Cesium.ScreenSpaceEventType.LEFT_UP | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment