Use Deepearth to load online Google Maps (satellite, street)

Source: Internet
Author: User
Tags silverlight

Any tilesource provided within the Deepearth is inherited from the DeepEarth.Layers.TileSource class, which implements the Multiscaletilesource class and the Itilesource interface. Together, the implementation of map layer loading and related algorithm strategy. We want to implement the principle of loading online Google Maps is very simple, find the Google online Map tile system mapping address, write map layer load algorithm strategy is OK.

In Deepearth.provider, there are many kinds of maps loaded Tilesource, we can directly modify one of them to implement the loading of Google online satellite map, the following for example, Bluemarble/bmtilesource, The constructor method of this class provides multiple overloaded versions, one of which is to accept a map tile system mapping address, so that we can pass the mapping address of tile system through an external invocation, in which we only need to modify the algorithm that loads the underlying map. The algorithm is adapted to load map data according to the mapping URL of Google's online satellite map, by rewriting the Tilesource GetTile method for the following code:

1 public override Uri gettile (int tilelevel, int tilepositionx, int tilepositiony)
2 {
3 if (isinitialized)
4 {
5 int zoom = Tiletozoom (Tilelevel);
6 _istiledownloadstarted = true;
7
8 String url = string. Empty;
9
Ten switch (mapmode)
11 {
Case Bmmapmodes.bluemarbleweb:
The URL = tilepathbluemarbleweb;
The URL = string. Format (URL, tilepositionx% 4, Tilepositionx, tilepositiony, zoom);
break;
16
Case Bmmapmodes.bluemarblelocal:
The URL = tilepathbluemarblelocal;
int port = Application.Current.Host.Source.Port;
The URL = string. Format (URL, zoom, Tilepositionx, Tilepositiony, Port);
21st
break;
23}
return new Uri (URL);
25}
-Return null;
27}

Because the enumeration type defaults to the first enumeration item, it is possible to modify the Bluemarbleweb mode directly above. In creating a new Silverlight application and host program, introduce the Deepearth control into the Silverlight application page and invoke the Deepearth map control.

xmlns:DeepEarth="clr-namespace:DeepEarth;assembly=DeepEarth"

The following is a sample code for the map control using Deepearth:

<Grid x:Name="LayoutRoot" Width="640" Height="480">
<StackPanel>
<DeepEarth:Map x:Name="map"  Canvas.ZIndex="1003">
</DeepEarth:Map>
</StackPanel>
</Grid>

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.