Supermap iclient for Silverlight load map

Source: Internet
Author: User
Tags silverlight

 

As follows:

Code:

<Usercontrol X: class = "syit. mainpage "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 "MC: ignorable =" D "xmlns: ic = "http://schemas.supermap.com/iclient/2010" xmlns: Is = "http://schemas.supermap.com/isdo Tnet/2010 "xmlns: Local =" CLR-namespace: syit. commonclass "D: designheight =" 300 "D: designwidth =" 400 "> <grid X: Name =" layoutroot "background =" white "> <IC: Map x: name = "mymap" viewboundschanged = "mymap_viewboundschanged"> <local: tiledtdtmapslayer id = "layer1" ismarks = "false" mode = "vector"> </local: tiledtdtmapslayer> <local: tiledtdtmapslayer id = "Layer2" ismarks = "true" mode = "vector"> </local: tiledtmapslayer> </IC: map> <border Height = "30" width = "150" verticalalignment = "TOP" horizontalalignment = "right"> <stackpanel orientation = "horizontal"> <radiobutton content = "vector map "Height =" 20 "ischecked =" true "horizontalalignment =" Left "name =" vectorradio "groupname =" layertype "verticalignment =" TOP "width =" 68 "Checked =" vectorradio_checked "/> <radiobutton content =" image map "Height =" 20 "horizontalalignment =" Left "name =" Erialradio "groupname =" layertype "verticalalignment =" TOP "width =" 68 "Checked =" aerialradio_checked "/> </stackpanel> </Border> <textblock X: name = "tblcoordinator" horizontalalignment = "Left" margin = "10, 0, 0, 0 "textwrapping =" Wrap "text =" "verticalalignment =" bottom "Height =" 19 "/> </GRID> </usercontrol> using system; using system. collections. generic; using system. collections. objectmodel; using system. LINQ; USI Ng system. net; using system. threading; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Supermap. web. actions; using Supermap. web. core; using Supermap. web. isdotnet6; using Supermap. web. mapping; using Supermap. web. service; using syit. commonclass; using Syit. ylz_servicereference; namespace syit {public partial class mainpage: usercontrol {private double oldscale = new double (); role layer_1 = new role (); tiledtdtmapslayer layer_2 = new tiledtdtmapslayer (); public mainpage () {initializecomponent (); this. mymap. viewbounds = new rectangle2d (New point2d (117.112306799734, 29.3397854999518), new point2d (118.981519200236, 30. 5753385000023); layer_1 = mymap. layers ["layer1"] As tiledtdtmapslayer; layer_2 = mymap. layers ["Layer2"] As tiledtdtmapslayer; mymap. mousemove + = new system. windows. input. mouseeventhandler (mymap_mousemove);} private void vectorradio_checked (Object sender, routedeventargs e) {layer_1.mode = tiledtdtmapslayer. layertype. vector; layer_2.mode = tiledtdtmapslayer. layertype. vector;} private void aeria Lradio_checked (Object sender, routedeventargs e) {layer_1.mode = tiledtmapslayer. layertype. aerial; layer_2.mode = tiledtdtmapslayer. layertype. aerial;} private void mymap_viewboundschanged (Object sender, viewboundseventargs e) {If (oldscale = 0) {oldscale = math. round (mymap. resolution, 10);} else if (oldscale! = Math. round (mymap. resolution, 10) {layer_2.refresh (); oldscale = math. round (mymap. resolution, 10) ;}} void mymap_mousemove (Object sender, system. windows. input. mouseeventargs e) {This. tblcoordinator. TEXT = mymap. screentomap (E. getposition (mymap )). tostring ();}}}
Using system; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. ink; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Supermap. web. core; using Supermap. web. mapping; namespace syit. commonclass {public class tiledtdtmapslayer: tiledcachedlayer {// define the basic URL priv Ate string [] subdomains = {"0", "1", "2", "3", "4", "5 "}; // URL private const string vectorgroup1 = "http: // tile {0} .tianditu.com/dataserver? T = a0512_emap & X = {1} & Y = {2} & l = {3} "; // URL private const string vectorgroup2 =" http: // tile {0} .tianditu.com/dataserver? T = b0627_emap1112 & X = {1} & Y = {2} & l = {3 }"; // URL private const string vectorgroup3 = "http: // tile {0} .tianditu.com/dataserver? T = siwei0608 & X = {1} & Y = {2} & l = {3} "; // URL private const string aerialgroup1 =" http: // tile {0} .tianditu.com/dataserver? T = sbsm0210 & X = {1} & Y = {2} & l = {3} "; // URL private const string aerialgroupleve11 =" http: // tile {0} .tianditu.com/dataserver? T = E11 & X = {1} & Y = {2} & l = {3} "; // URL private const string aerialgroupleve12 =" http: // tile {0} .tianditu.com/dataserver? T = E12 & X = {1} & Y = {2} & l = {3} "; // URL private const string aerialgroupleve13 =" http: // tile {0} .tianditu.com/dataserver? T = E13 & X = {1} & Y = {2} & l = {3} "; // URL private const string aerialgroupleve14 =" http: // tile {0} .tianditu.com/dataserver? T = eastdawnall & X = {1} & Y = {2} & l = {3 }"; // URL private const string aerialgroupleve15 = "http: // tile {0} .tianditu.com/dataserver? T = sbsm1518 & X = {1} & Y = {2} & l = {3 }"; // Image Layer zoom Level 2-10 URL of map markup text private const string aerialmarksgroup1 = "http: // tile {0} .tianditu.com/dataserver? T = a0610_imganno & X = {1} & Y = {2} & l = {3 }"; // URL private const string aerialmarksgroup2 = "http: // tile {0} .tianditu.com/dataserver? T = b0530_eimganno & X = {1} & Y = {2} & l = {3 }"; // URL private const string aerialmarksgroup3 = "http: // tile {0} .tianditu.com/dataserver? T = siweianno68 & X = {1} & Y = {2} & l = {3 }"; // URL private const string vectormarks = "http: // tile {0} .tianditu.com/dataserver? T = ab0512_anno & X = {1} & Y = {2} & l = {3} "; // you can specify whether to display the map markup text. When the image is a text layer, false indicates the map layer public bool ismarks {Get; set;} private double [] scales = NULL; // defines the map type dependency attribute public layertype mode {get {return (layertype) getvalue (maptypeproperty);} set {setvalue (maptypeproperty, value);} public static readonly dependencyproperty maptypeproperty = dependencyproperty. register ("Mode", typeof (layertype), typeof (tiledtd Tmapslayer), new propertymetadata (New propertychangedcallback (onmaptypepropertychanged); Private Static void onmaptypepropertychanged (dependencyobject d, e) {callback layer = D as Callback; if (layer. isinitialized) {layer. changetilesource () ;}}// set the map type and refresh private void changetilesource () {If (! Base. isinitialized) {base. initialize ();} else {base. refresh () ;}} public tiledtdtmapslayer () {} public override void initialize () {This. url = vectorgroup1; this. bounds = new rectangle2d (-179.99999999999997,-90.0, 180.00000000000023, 89.99999999999994); this. resolutions = new double [] {0.35156249999999994, 0.17578124999999997, 0.08789062500000014, 0.04394531250000007, 0.021972656250000007, 0.01098632812500002, 0.00549316406250001, 0.0027465820312500017, 0.0013732910156250009, 0.000686645507812499, 0.0003433227539062495, 0.00017166137695312503, 0.00008583068847656251, 0.000042915344238281406, 0.000021457672119140645, 0.000010728836059570307, 0.000005364418029785169}; base. initialize () ;}// rewrite the returned URL function public override string gettileurl (INT indexx, int indexy, int level) {level + = 2; Switch (this. mode) {Case layertype. vector: If (level> = 13 & level <= 18) {This. url = vectorgroup3;} If (level> = 11 & level <= 12) {This. url = vectorgroup2;} If (level> = 2 & level <= 10) {If (this. ismarks) {This. url = vectormarks;} else {This. url = vectorgroup1;} break; Case layertype. aerial: If (level> = 2 & level <= 10) {If (ismarks) {This. url = aerialmarksgroup1;} else {This. url = aerialgroup1 ;}}if (Level = 11) {If (ismarks) {This. url = aerialmarksgroup2;} else {This. url = aerialgroupleve11 ;}} if (Level = 12) {If (ismarks) {This. url = aerialmarksgroup2;} else {This. url = aerialgroupleve12 ;}} if (Level = 13) {If (ismarks) {This. url = aerialmarksgroup2;} else {This. url = aerialgroupleve13 ;}} if (Level = 14) {If (ismarks) {This. url = aerialmarksgroup2;} else {This. url = aerialgroupleve14 ;}} if (level> = 15) {If (ismarks) {This. url = aerialmarksgroup3;} else {This. url = aerialgroupleve15 ;}} break;} return string. format (this. URL, 1, indexx, indexy, level);} public Enum layertype {vector, aerial }}}

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.