SpatialAnchorStore SpatialAnchorStore SpatialAnchorStore SpatialAnchorStore Class

Definition

Represents a collection of SpatialAnchor objects stored by Windows on behalf of an app.

public : sealed class SpatialAnchorStore : ISpatialAnchorStorepublic sealed class SpatialAnchorStore : ISpatialAnchorStorePublic NotInheritable Class SpatialAnchorStore Implements ISpatialAnchorStore// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10586.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

This lets an app persist SpatialAnchors and then load them back again during a future app session. The app is responsible for keeping track of which identifiers represent which logical locations within the app, for example associating an anchor with a hologram that should be displayed there.

To request the app's SpatialAnchorStore, use the SpatialAnchorManager class.

Methods

Clear() Clear() Clear() Clear()

Clears all anchors in the app's anchor store.

public : void Clear()public void Clear()Public Function Clear() As void// You can use this method in JavaScript.

GetAllSavedAnchors() GetAllSavedAnchors() GetAllSavedAnchors() GetAllSavedAnchors()

Gets a map of all anchors saved in the store, with their identifiers as the keys.

public : IMapView<PlatForm::String, SpatialAnchor> GetAllSavedAnchors()public IReadOnlyDictionary<string, SpatialAnchor> GetAllSavedAnchors()Public Function GetAllSavedAnchors() As IReadOnlyDictionary( Of string, SpatialAnchor )// You can use this method in JavaScript.
Returns
IMapView<PlatForm::String, SpatialAnchor> IReadOnlyDictionary<string, SpatialAnchor> IReadOnlyDictionary<string, SpatialAnchor> IReadOnlyDictionary<string, SpatialAnchor>

The map of anchors.

Remove(String) Remove(String) Remove(String) Remove(String)

Removes a specific anchor from the store. The anchor is specified by its identifier.

public : void Remove(PlatForm::String id)public void Remove(String id)Public Function Remove(id As String) As void// You can use this method in JavaScript.
Parameters
id
PlatForm::String String String String

The identifier of the anchor to remove.

TrySave(String, SpatialAnchor) TrySave(String, SpatialAnchor) TrySave(String, SpatialAnchor) TrySave(String, SpatialAnchor)

Persists an anchor to the store.

public : PlatForm::Boolean TrySave(PlatForm::String id, SpatialAnchor anchor)public bool TrySave(String id, SpatialAnchor anchor)Public Function TrySave(id As String, anchor As SpatialAnchor) As bool// You can use this method in JavaScript.
Parameters
id
PlatForm::String String String String

An identifier for the anchor. The identifier must be unique within your app.

Returns
PlatForm::Boolean bool bool bool

True, if the save succeeded; otherwise, false.

Remarks

This method may return false in future versions of Windows if a device has a per-app anchor persistence limit.