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>