Silverlight Bing Maps loads 3D (fake) maps

Source: Internet
Author: User

Step 1. Create a 3D Building in sketch up:

Most people may think of powerful 3 DMAX for creating 3D buildings, but I recommend concise sketch up here. The following figure shows the created 3D model, which looks a little gray (because no rendering processing is performed ).

After the model is created, you can adjust the model to a proper angle and export the 2D graphic to JPG format.

Step 2. Use mapcruncher for map Slicing

Here we use Microsoft's map slicing tool mapcruncher: http://research.microsoft.com/en-us/um/redmond/projects/mapcruncher/

There are also specific teaching materials. Here I will do the simple slicing steps:

1. Import the image we exported in the previous step.

2. Then we can see our 3D map in the Left view.

3. The next step is to start registration, that is, to determine the actual geographical location of your model. Generally, we need three vertices for registration.

Add three registration coordinate points (point1, point2, and point3)

4. Click render to slice (slice takes some time ).

5. Finally, we can see the cut graph in the saved Folder:

Step 3. Next we will start to read these slices in Silverlight.

First, put the slice folder saved in the previous step under C: \ Inetpub \ wwwroot,

Compile a custom 3dm3dtilesource to load the map we have deployed:

 public class Custom3DTileSource : LocationRectTileSource
{

private const string baseUrl = "http://localhost/3DMapLayer/{0}.png";
public Custom3DTileSource()
: base(baseUrl, new LocationRect(new Location(60, 60), new Location(13, 140)),
new Range<double>(1, 17))
{ }


public override Uri GetUri(int x, int y, int zoomLevel)
{
return new Uri(string.Format(this.UriFormat, TileXYToQuadKey(x, y, zoomLevel)), UriKind.RelativeOrAbsolute);
}


private static string TileXYToQuadKey(int tileX, int tileY, int levelOfDetail)
{
StringBuilder quadKey = new StringBuilder();
for (int i = levelOfDetail; i > 0; i--)
{
char digit = '0';
int mask = 1 << (i - 1);
if ((tileX & mask) != 0)
{
digit++;
}
if ((tileY & mask) != 0)
{
digit++;
digit++;
}
quadKey.Append(digit);
}
return quadKey.ToString();
}
}

Then we can use custom3dtilesource to load the map.

public partial class _3DMapViews : UserControl
{
MapTileLayer mapTileLayer = new MapTileLayer();
public _3DMapViews()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(_3DMapViews_Loaded);
}

void _3DMapViews_Loaded(object sender, RoutedEventArgs e)
{
Custom3DTileSource cts = new Custom3DTileSource();
mapTileLayer.TileSources.Add(cts);
my3DMap.Mode = new MercatorMode();
my3DMap.Center = new Location(25.18, 119.50);
my3DMap.Children.Add(mapTileLayer);
}
}

The final result is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.