Navigating – Creating a Fly To

This example shows how to fly to a specific position on the terrain. This example uses the ICreator61 (CreatePosition)and INavigate61 (FlyTo) methods.

 

function FlyTo()

        {

            try

            {

                // x,y,height, height type, yaw, pitch, roll, distance

                var newYork = sgworld.Creator.CreatePosition(-74, 40.716667, 1000, 0 /* AltitudeTypeCode.ATC_TERRAIN_RELATIVE*/, 0, -45, 0, 0);

                // x,y,height, height type, yaw, pitch, roll, distance

                var losAngeles = sgworld.Creator.CreatePosition(-118.25, 34.05, 1000, 0 /*AltitudeTypeCode.ATC_TERRAIN_RELATIVE*/, 0, -45, 0, 0);

                if (_evenCall)

                {

                    alert("Click ok to fly to New York city");

                    sgworld.Navigate.FlyTo(newYork);

                }

                else

                {

                    alert("Click ok to fly to Los Angeles");

                    sgworld.Navigate.FlyTo(losAngeles);

                }

                _evenCall = !_evenCall;

            }

            catch (ex)

            {

                alert("Unexpected error: " + ex.description);

            }

        }