UWP maps, add 3D object
Asked Answered
D

1

6

I would like to add 3D object in Windows 10 UWP map control.

This object would be "polygon with height", e.g. simple representation of a house - cuboid or cube.

Illustration image:

Illustration

I know that I can add Xaml control (and inside it 3D object e.g. Cube) but then this Cube is not 'map object', only pinned to a certain Lat/Lon.

Any idea how to implement this?

Deviationism answered 21/7, 2016 at 12:35 Comment(2)
I don't believe there's a way to add 3D shapes on the map control yet. Sorry :\Meridel
Thank you for your reply @S.Matthews Unfortunately not good news. Anybody else has some suggestion/idea ?Deviationism
B
5

Microsoft has added MapElement3D in Windows 10 Insider Preview v10.0.16257.0. - that's the falls creators update. It allows you to add objects, turn them, control their size, and direction. You can make them move too!

Example

Example

How-To

Represents a 3D element displayed on a MapControl.

It's usage appears to be very similar to other MapElements, such as 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);   

Beware of two undocumented issues:

  • Attempting to add the same 3DMapElement to two different MapControls will result in System.AccessViolationException. This can happen if you cached the 3D model but not the page with the map control.

HResult=-2147467261 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

  • Attempting to call MapModel3D.CreateFrom3MFAsync() from a non-Ui thread will cause a crash. This must be called from a UI thread.
Bynum answered 7/7, 2017 at 0:51 Comment(1)
Hi! Would u mind provide a link to your example, please?Sinistrous

© 2022 - 2024 — McMap. All rights reserved.