Use DeepEarth to load online Google Maps (satellites and streets)

Source: Internet
Author: User

This article briefly introduces the basic structure of DeepEarth and the basic usage of TileSource for maps. This article uses a simple application example to load online google satellite maps) continue to introduce the DeepEarth control usage.

 

Any TileSource provided by DeepEarth inherits from the DeepEarth. Layers. TileSource class, which implements the MultiScaleTileSource class and the ITileSource interface, and completes the loading of map Layers and related algorithm policies. The principle of loading online Google maps is very simple. Find the Tile System ing address of Google online maps and compile the map layer loading algorithm policy.

 

In DeepEarth. the Provider provides many types of TileSource for map loading. We can directly modify one of them to load Google online satellite maps. The following uses BlueMarble/BmTileSource as an example, the constructor of this class provides multiple overloaded versions. One of them accepts a map Tile System ing address. In this way, we can pass in the ing address of Tile System during external calls, in this class, we only need to modify the algorithm that loads the bottom layer of the map, so that this algorithm can adapt to Loading map data according to the ing Url of the Google online satellite map, you can simply rewrite the GetTile method of TileSource to 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
10 switch (MapMode)
11 {
12 case BmMapModes. BlueMarbleWeb:
13 url = TilePathBlueMarbleWeb;
14 url = string. Format (url, tilePositionX % 4, tilePositionX, tilePositionY, zoom );
15 break;
16
17 case BmMapModes. BlueMarbleLocal:
18 url = TilePathBlueMarbleLocal;
19 int port = Application. Current. Host. Source. Port;
20 url = string. Format (url, zoom, tilePositionX, tilePositionY, port );
21
22 break;
23}
24 return new Uri (url );
25}
26 return null;
27}

 

 

Because the enumeration type is the first enumeration item by default, you can directly modify the BlueMarbleWeb mode above. Create a Silverlight application and Host Program, introduce the DeepEarth control on the Silverlight application page, and call the Map control of DeepEarth.

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

 

The following is an example code of 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>

 

 

The Map control is also used on the interface. You only need to specify a TileSource for the control layer to load Map data. HttpWatch and other tools can be used to analyze the Tile System ing address of Google's online satellite map: http: // khm {0}. The following code:

1 public MainPage ()
2 {
3 InitializeComponent ();
4 map. BaseLayer. Source = new BmTileSource ("http: // khm {0} .google.com/kh/v?47&x==1}&y=%2}&z=%3 }");
5}

 

 

        

Compile and run the program as above (Chongqing chaotianmen wharf ). We can also modify the constant TilePathBlueMarbleWeb in BmTileSource as follows:

Private const string TilePathBlueMarbleWeb = @ "http: // khm {0} .google.com/kh/v?47&x==1}&y=%2}&z=%3 }";

 

In this way, when using BmTileSource, you can also set the BmMapModes parameter through the constructor to determine the loaded map:

1 public MainPage ()
2 {
3 InitializeComponent ();
4
5 // map. BaseLayer. Source = new BmTileSource ("http: // khm {0} .google.com/kh/v?47&x==1}&y=%2}&z=%3 }");
6 map. BaseLayer. Source = new BmTileSource (BmMapModes. BlueMarbleWeb );
7}

 

Similarly, we can also load online Google street maps. Google's street map loading algorithm is the same as that of satellite maps. The difference is that the Tile System ing address of street maps. You can also use HttpWatch and other sniffer tools to obtain the address format of the Google street map: http: // mt {0} region. To load a Google street map, you only need to modify it:

Private const string TilePathBlueMarbleWeb = @ "http: // khm {0} .google.com/kh/v?47&x==1}&y=%2}&z=%3 }";

 

You can map the address of the Tile System of the Google street map. The Code is as follows:

Private const string TilePathBlueMarbleWeb = @ "http: // mt {0} success"

        

 

If we have Google map data, we can also deploy map data on our own, and then load the Google map data we have deployed. We will not detail it here, if you are interested, please refer to another article: [Silverlight] Bing Maps Learning Series (8): loading your deployed Google Maps using Bing Maps Silverlight Control.

 

Description

This document is a learning note and is intended to be shared with people with lofty ideals. You are welcome to repost this article, but mark the original article connection in a prominent position.

Author: Beniao WebGIS technology group: 75662563

Article Source: http://beniao.cnblogs.com/or http://www.cnblogs.com/

 

 

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.