From e218e9d42bae88667a4d9dd0376f68d273c0b731 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Wed, 14 Oct 2015 14:31:42 -0400 Subject: [PATCH] geocoder uses flyto logic --- Source/Scene/Camera.js | 4 +++ Source/Widgets/Geocoder/GeocoderViewModel.js | 27 +++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Source/Scene/Camera.js b/Source/Scene/Camera.js index 2b665f8cdf1e..4c03716f8140 100644 --- a/Source/Scene/Camera.js +++ b/Source/Scene/Camera.js @@ -2019,6 +2019,10 @@ define([ //>>includeEnd('debug'); ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84); + if (this._mode !== SceneMode.SCENE3D && rectangle.west > rectangle.east) { + rectangle = Rectangle.MAX_VALUE; + } + if (this._mode === SceneMode.SCENE3D) { rectangleCameraPosition3D(this, rectangle, ellipsoid, this.position); } else if (this._mode === SceneMode.COLUMBUS_VIEW) { diff --git a/Source/Widgets/Geocoder/GeocoderViewModel.js b/Source/Widgets/Geocoder/GeocoderViewModel.js index 5a5e56a38a24..28d92d788e60 100644 --- a/Source/Widgets/Geocoder/GeocoderViewModel.js +++ b/Source/Widgets/Geocoder/GeocoderViewModel.js @@ -10,6 +10,7 @@ define([ '../../Core/jsonp', '../../Core/Matrix4', '../../Core/Rectangle', + '../../Scene/SceneMode', '../../ThirdParty/knockout', '../../ThirdParty/when', '../createCommand' @@ -24,6 +25,7 @@ define([ jsonp, Matrix4, Rectangle, + SceneMode, knockout, when, createCommand) { @@ -201,13 +203,22 @@ define([ } }); - function updateCamera(viewModel, position) { + var scratchPosition = new Cartesian3(); + function updateCamera(viewModel, destination) { + var scene = viewModel._scene; if (viewModel._flightDuration === 0) { - viewModel._scene.camera.setView({position: position}); + var isRectangle = defined(destination.west); + if (isRectangle) { + if (scene.scene.mode !== SceneMode.SCENE3D && destination.west > destination.east) { + destination = Rectangle.MAX_VALUE; + } + destination = scene.camera.getRectangleCameraCoordinates(destination, scratchPosition); + } + viewModel._scene.camera.setView({position: destination}); viewModel._complete.raiseEvent(); } else { viewModel._scene.camera.flyTo({ - destination : position, + destination : destination, complete: function() { viewModel._complete.raiseEvent(); }, @@ -275,16 +286,8 @@ define([ var west = bbox[1]; var north = bbox[2]; var east = bbox[3]; - var rectangle = Rectangle.fromDegrees(west, south, east, north); - - var camera = viewModel._scene.camera; - var position = camera.getRectangleCameraCoordinates(rectangle); - if (!defined(position)) { - // This can happen during a scene mode transition. - return; - } - updateCamera(viewModel, position); + updateCamera(viewModel, Rectangle.fromDegrees(west, south, east, north)); }, function() { if (geocodeInProgress.cancel) { return;