UWP 地图,添加 3D 对象
UWP maps, add 3D object
我想在 Windows 10 UWP 地图控件中添加 3D 对象。
此对象将是 "polygon with height",例如房子的简单表示 - 长方体或立方体。
插图图片:
我知道我可以添加 Xaml 控件(并在其中添加 3D 对象,例如立方体),但此立方体不是 'map object',仅固定到某个 Lat/Lon。
知道如何实现吗?
Microsoft 已添加 MapElement3D in Windows 10 Insider Preview v10.0.16257.0. - 这是秋季创作者更新。它允许您添加对象、转动它们、控制它们的大小和方向。你也可以让他们动起来!
例子
操作方法
Represents a 3D element displayed on a MapControl.
它的用法似乎与其他 MapElements 非常相似,例如 MapIcons and MapBillboards。
map3dSphereStreamReference = RandomAccessStreamReference.CreateFromUri
(new Uri("ms-appx:///Assets/trainengine.3mf"));
var myModel = await MapModel3D.CreateFrom3MFAsync(map3dSphereStreamReference,
MapModel3DShadingOption.Smooth);
var my3DElement = new MapElement3D();
my3DElement.Location = myMap.Center;
my3DElement.Model = myModel;
myMap.MapElements.Add(my3DElement);
注意两个未记录的问题:
- 尝试将相同的 3DMapElement 添加到两个不同的 MapControl 将导致 System.AccessViolationException。如果您缓存了 3D 模型而不是带有地图控件的页面,就会发生这种情况。
HResult=-2147467261 Message=Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
- 尝试从非 Ui 线程调用
MapModel3D.CreateFrom3MFAsync()
将导致崩溃。这必须从 UI 线程调用。
我想在 Windows 10 UWP 地图控件中添加 3D 对象。
此对象将是 "polygon with height",例如房子的简单表示 - 长方体或立方体。
插图图片:
我知道我可以添加 Xaml 控件(并在其中添加 3D 对象,例如立方体),但此立方体不是 'map object',仅固定到某个 Lat/Lon。
知道如何实现吗?
Microsoft 已添加 MapElement3D in Windows 10 Insider Preview v10.0.16257.0. - 这是秋季创作者更新。它允许您添加对象、转动它们、控制它们的大小和方向。你也可以让他们动起来!
例子
操作方法
Represents a 3D element displayed on a MapControl.
它的用法似乎与其他 MapElements 非常相似,例如 MapIcons and MapBillboards。
map3dSphereStreamReference = RandomAccessStreamReference.CreateFromUri
(new Uri("ms-appx:///Assets/trainengine.3mf"));
var myModel = await MapModel3D.CreateFrom3MFAsync(map3dSphereStreamReference,
MapModel3DShadingOption.Smooth);
var my3DElement = new MapElement3D();
my3DElement.Location = myMap.Center;
my3DElement.Model = myModel;
myMap.MapElements.Add(my3DElement);
注意两个未记录的问题:
- 尝试将相同的 3DMapElement 添加到两个不同的 MapControl 将导致 System.AccessViolationException。如果您缓存了 3D 模型而不是带有地图控件的页面,就会发生这种情况。
HResult=-2147467261 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
- 尝试从非 Ui 线程调用
MapModel3D.CreateFrom3MFAsync()
将导致崩溃。这必须从 UI 线程调用。