ArcGIS for WPF access external resources

Source: Internet
Author: User

Application background:

Because the project needs to try to understand development technologies such as ArcGIS, Bing Map, and Google Map, it finally writes a Demo using ArcGIS.

ArcGIS now provides a set of control library ArcGIS API for WPF for Silverlight development and use, including controls that can be used by WPF.

Compared with the Sample Demo and hands-on practices, I am familiar with the control structure quickly. However, for those who have been using WPF for more than a year, I feel that the control library developer is still the idea of Winform, it does not take advantage of WPF Data Binding and templates.

The maps provided by ArcGIS on the Internet are relatively simple. At first glance, they seem very different from the Google Maps and Baidu maps we usually use (maybe I didn't know the essence ), after searching, we made the following attempts, that is, the topic of this article-ArcGIS accessing external resources.

  

References:

  ArcGIS API for Silverlight Development (7): use layers of non-AGS data sources

The 404 error is reported in the message behind the article. I didn't get the data when I was just trying to do it. I guess it's time for the Data Url to pass through, as the author said, later, when studying the GMap source code, I found that it also used the Google Map data source. After debugging and tracking, I got the approximate path, replaced the baseUrl, and finally showed me the Map image. Below is the modified TiledMapServiceLayer:

GoogleMapTileLayer

Public class GoogleMapTileLayer: TiledMapServiceLayer
{
Public override void Initialize ()
{
This. FullExtent = new Envelope (-20037508.342787,-20037508.342787, 20037508.342787, 20037508.342787 );{
SpatialReference = new SpatialReference (102113 );
};
This. SpatialReference = new SpatialReference (102113 );
This. TileInfo = new TileInfo ()
{
Height = 256,
Length = 256,

Origin = new MapPoint (-20037508.342787, 20037508.342787 ){
SpatialReference = new SpatialReference (0, 102113)
},
Lods = new dump [20]
};

Double resolution = 156543.033928;
For (int I = 0; I <TileInfo. Lods. Length; I ++)
{
TileInfo. Lods [I] = new LD () {Resolution = resolution };
Resolution/= 2;
}

Base. Initialize ();
}

Public override string gettileurl (INT level, int row, int col)
{String baseurl = "http://mt3.google.cn/vt/lyrs=m@156000000&hl=zh-CN&x= ";
String url = baseurl + Col. tostring () + "& Y =" + row. tostring () + "& Z =" + level. tostring () + "& s = ";
Return URL;
}
}

Use this layer in XAML:

<Esri: Map. Layers>
<WPFControlLibary: GoogleMapTileLayer/>
</Esri: Map. Layers>

Because the map displays the Chongqing region at the beginning, you need to specify envelope, and add the ready-made tools such as navigation and scaling. The complete map usercontrol code is as follows:

Map Control

<UserControl xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
Xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
Xmlns: esri = "http://schemas.esri.com/arcgis/client/2009"
Xmlns: I = "http://schemas.microsoft.com/expression/2010/interactivity"
Xmlns: local = "clr-namespace: NPView. View. WPFControl"
X: Class = "GISBrowserCtl">

<Grid X: Name = "layoutroot">
<ESRI: Map x: Name = "mymap"
Mousedown = "mymap_mousedown">
<ESRI: map. extent>
& Lt; ESRI: envelope xmin = "11841331.013437796"
Ymin = "3434962.1416729852"
Xmax = "11872920.415001778"
Ymax = "3453477.0409229854">
<ESRI: envelope. spatialreference>
<ESRI: spatialreference wkid = "102113" type = "parmname" text = "parmname"/>
</ESRI: envelope. spatialreference>
</ESRI: envelope>
</ESRI: map. extent>
<ESRI: map. Layers>
<Wpfcontrollibary: googlemaptilelayer/>
</ESRI: map. Layers>
<I: interaction. behaviors>
<Esri: MaintainExtentBehavior/>
</I: Interaction. Behaviors>
</Esri: Map> </Grid>
</UserControl>

Appendix

  ArcGIS API for Silverlight development (8): Using Virtual Earth services in a program

We can also use this service to make Virtual Earth services. However, the process is complicated and legal, and it is easy to use Bing Map in ArcGIS!

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.