This document is archived and information here might be outdated.  Recommended version.


How to create and zoom to a bookmark in globe (ArcObjects .NET 10.5 SDK)

How to create and zoom to a bookmark in globe


Summary
Bookmarks in 3D are saved camera perspectives. When using bookmarks, you can zoom to or revisit a location that is of importance.

In this topic


Creating and zooming to a bookmark in globe

To create bookmarks in globe, the IBookmark3D interface is used. Bookmarks are stored in ISceneBookmarks, which acts like a container.
To create and zoom to a bookmark in globe, perform the following steps:
  1. Get a handle to the bookmarks in the current scene as shown in the following code example:
[C#]
ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay=globe.GlobeDisplay;
ESRI.ArcGIS.Analyst3D.IScene scene=globeDisplay.Scene;
ESRI.ArcGIS.Analyst3D.ISceneBookmarks sceneBookmarks=
    (ESRI.ArcGIS.Analyst3D.ISceneBookmarks)scene; // Explicit cast.
[VB.NET]
Dim globeDisplay As ESRI.ArcGIS.GlobeCore.IGlobeDisplay=globe.GlobeDisplay
Dim scene As ESRI.ArcGIS.Analyst3D.IScene=globeDisplay.Scene
Dim sceneBookmarks As ESRI.ArcGIS.Analyst3D.ISceneBookmarks=CType(scene, ESRI.ArcGIS.Analyst3D.ISceneBookmarks) ' Explicit Cast
  1. Since 3D bookmarks are saved camera perspectives, get a handle to the camera of the active viewer as shown in the following code example. Other properties of the bookmark can also be set.
[C#]
ESRI.ArcGIS.Analyst3D.ICamera camera=globeDisplay.ActiveViewer.Camera;
[VB.NET]
Dim camera As ESRI.ArcGIS.Analyst3D.ICamera=globeDisplay.ActiveViewer.Camera
  1. Use the current camera locations to create and capture bookmarks and add them to the scene. See the following code example:
[C#]
ESRI.ArcGIS.Analyst3D.IBookmark3D bookmark=new ESRI.ArcGIS.Analyst3D.Bookmark3D();

bookmark.Capture(camera);
bookmark.Name="Bookmark 1";

sceneBookmarks.AddBookmark(bookmark);
[VB.NET]
Dim bookmark As ESRI.ArcGIS.Analyst3D.IBookmark3D=Nothing

bookmark.Capture(camera)
bookmark.Name="Bookmark 1"
sceneBookmarks.AddBookmark(bookmark)
  1. Get a handle to the scene bookmarks (ISceneBookmarks) as previously shown, and specify the bookmark to zoom to. The following code example shows how to find a bookmark in the current scene by name:
[C#]
ESRI.ArcGIS.Analyst3D.IBookmark3D pBookmark;

sceneBookmarks.FindBookmark("Bookmark 1", out pBookmark);
[VB.NET]
Dim pBookmark As ESRI.ArcGIS.Analyst3D.IBookmark3D=Nothing

sceneBookmarks.FindBookmark("Bookmark 1", pBookmark)
  1. Zoom to the bookmark by applying the camera properties to the current active viewer as shown in the following code example:
[C#]
pBookmark.Apply(globeDisplay.ActiveViewer, false, 0);
[VB.NET]
pBookmark.Apply(globeDisplay.ActiveViewer, False, 0)

Globe navigation modes

The two navigation modes in globe are surface navigation and globe navigation. If the bookmark you want to zoom to was saved in either mode, make sure that after zooming to the bookmark, you also set the navigation mode.

Surface navigation mode

In surface navigation mode, the camera is set at the surface and X, Y, Z have a nonzero value. If that is the case, set the navigation mode of the globe camera to surface navigation mode.

Globe navigation mode

In globe navigation mode, the camera target has (X, Y, Z) equal to (0, 0, 0). Query to see if the camera target is set to (0, 0, 0). If it is, set the navigation mode of the globe camera to globe navigation mode. After setting the navigation mode, refresh the active viewer. See the following code example:
[C#]
ESRI.ArcGIS.Analyst3D.ICamera camera=globeDisplay.ActiveViewer.Camera;
ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera=(IGlobeCamera)camera; 
    // Explicit cast.

double pXT, pYT, pZT;
camera.Target.QueryCoords(out pXT, out pYT);

pZT=camera.Target.Z;

globeCamera=(ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera; // Explicit cast. 

if ((pXT * pXT + pYT * pYT + pZT * pZT) < 0.000000000001)
    globeCamera.OrientationMode =
        esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal;
else
    globeCamera.OrientationMode =
        esriGlobeCameraOrientationMode.esriGlobeCameraOrientationLocal;

globeDisplay.ActiveViewer.Redraw(true);
[VB.NET]
Dim camera As ESRI.ArcGIS.Analyst3D.ICamera=sceneViewer.Camera
Dim globeCamera As ESRI.ArcGIS.GlobeCore.IGlobeCamera=CType(camera, ESRI.ArcGIS.GlobeCore.IGlobeCamera) ' Explict Cast

Dim pXT As System.Double=0
Dim pYT As System.Double=0
camera.Target.QueryCoords(pXT, pYT)

Dim pZT As System.Double
pZT=camera.Target.Z

If (pXT * pXT + pYT * pYT + pZT * pZT) < 0.000000000001 Then
    globeCamera.OrientationMode=ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal
Else
    globeCamera.OrientationMode=ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationLocal
End If

sceneViewer.Redraw(True)






Development licensing Deployment licensing
Engine Developer Kit Engine: 3D Analyst
ArcGIS Desktop Basic: 3D Analyst ArcGIS Desktop Basic: 3D Analyst
ArcGIS Desktop Standard: 3D Analyst ArcGIS Desktop Standard: 3D Analyst
ArcGIS Desktop Advanced: 3D Analyst ArcGIS Desktop Advanced: 3D Analyst