ArcGIS API for Silverlight write a layer to access Google Map

Source: Internet
Author: User
Tags silverlight

The arcgistiledmapservicelayer layer in ArcGIS API for Silverlight inherits from tiledmapservicelayer. If you want to implement your own cache map layer, inherit it and reload the gettileurl method. ArcGIS API for Silverlight internally calculates the current access scaling level, slice two-dimensional number row, Col. These parameters are exposed to the gettileurl method. In this method, set the URL to access the Google static map.

Public class googlemaplayer: tiledmapservicelayer
{
Private const double cornercoordinate = 20037508.3427892;
Public override void initialize ()
{
This. fullextent = new ESRI. ArcGIS. Client. Geometry. Envelope (-20037508.3427892,-20037508.3427892, 20037508.3427892, 20037508.3427892)
{
Spatialreference = new spatialreference (0, 102100)
};
// This layer's spatial reference
This. spatialreference = new spatialreference (102100 );
// Set up tile information. Each tile is 256x256px, 19 levels.
This. tileinfo = new tileinfo ()
{
Height = 256,
Length = 256,
Origin = new mappoint (-cornercoordinate, cornercoordinate) {spatialreference = new ESRI. ArcGIS. Client. Geometry. spatialreference (102100 )},
Lods = new d3[ 19]
};
// Set the resolutions for each level. Each level is half the resolution of the previous one.
Double resolution = cornercoordinate * 2/256;
For (INT I = 0; I <tileinfo. lods. length; I ++)
{
Tileinfo. lods [I] = new LD () {resolution = resolution };
Resolution/= 2;
}
// Call base initialize to raise the initialization event
Base. initialize ();
}

Public override string gettileurl (INT level, int row, int col)
{
String baseurl = "plaintext ";

Return string. Format (baseurl, Col, row, level );
}
}

 

You can also download the test results at http://download.csdn.net/detail/leesmn/3636647.

 

 

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.