The previous article introduced the theoretical basis of gmap.net, which describes how to integrate a gold map. The gold map has been known to the public since it provided maps for IOS6.
In my experience of integrating domestic maps, it is also most consistent with the Mercator projection method.
Links to previous related articles:
Deep understanding of the strongest desktop map control gmap.net---Principle
Deep understanding of the strongest desktop map control gmap.net---soso map
Deep understanding of the strongest desktop map controls gmap.net---Baidu map
In-depth understanding of the strongest desktop map control gmap.net---First use
Deep understanding of the strongest desktop map control gmap.net---first knowledge
How to use gmap.net Gold map in your program
To use the following code, it is recommended to look at the first article, the specific code is as follows.
This. Mainmap.position = new POINTLATLNG (double. Parse (configurationmanager.appsettings["Defaultlat"]), double. Parse (configurationmanager.appsettings["defaultlng")); MainMap.MapProvider.Area = new Rectlatlng (30.981178, 105.351914, 2.765142, 4.120995); Mainmap.boundsofmap = new Rectlatlng (30.981178, 105.351914, 2.765142, 4.120995); MainMap.Manager.Mode = Accessmode.cacheonly;this. Mainmap.mapprovider = Gmapproviders.amapprovider;this. Mainmap.dragbutton = Mousebutton.left;this. Mainmap.zoom = 13;this. Mainmap.minzoom = 8;this. Mainmap.maxzoom = 24;
gmap.net The effect of the German map
General Map
Satellite map
The principle of the loading of German maps
To understand how to load the gold map, but also to understand the loading principle, we use chrome to open the http://www.amap.com/, arbitrarily locate an address, open the developer tool:
You can see the tile's address as follows: http://webrd03.is.autonavi.com/appmaptile?x=1629&y=849&z=11&lang=zh_cn&size=1 &scale=1&style=7
We analyze the URL link parameters:
Http://webrd03.is.autonavi.com/appmaptile is fixed.
&lang=zh_cn&size=1&scale=1&style=7 is also fixed.
x=1629 is the horizontal axis of the grid, y=849 is the vertical axis of the grid, the formation of the horizontal ordinate principle has been described in the principle, here will not repeat.
Z=11 is the current zoom level.
So the German map is relatively simple and normative.
Let's take a look at how to implement the Gmap.net map in the next section.
Amapprovider
As with the operation flow of Baidu map, the following process is also used to add amapprovider support.
1) Add abstract class Amapproviderbase
Since the German map also has regular maps and satellite maps, it provides an abstract class with public methods that can be reused.
PublicAbstractClassAmapproviderbase:gmapprovider {PublicAmapproviderbase () {maxzoom =Null; Refererurl ="http://www.amap.com/"; Copyright =String. Format ("©{0} corporation,©{0} navteq,©{0} Image courtesy of NASA", DateTime.Today.Year); }public overrideget {return Mercatorprojection.instance; }} gmapprovider[] overlays; public overrideget {if (Overlays = = nullnew gmapprovider[] {this};} return Overlays;}} }
2). AMapprovider
is mainly The Maketileimageurl method is based on the search map loading principle: Essentially, a URL link to get a picture is constructed, such as:http://webrd03.is.autonavi.com/appmaptile?x=1629& y=849&z=11&lang=zh_cn&size=1&scale=1&style=7).
PublicClassAmapprovider:amapproviderbase {PublicStaticReadOnlyAmapprovider Instance;ReadOnly Guid ID =New Guid ("Ef3dd303-3f74-4938-bf40-232d0595ee88");PublicOverrideGuid Id {get {ReturnId } }ReadOnlyString name ="AMap";PublicOverrideStringName {Get{ReturnName } }StaticAmapprovider () {Instance =NewAmapprovider (); }PublicOverride Pureimage Gettileimage (Gpoint pos,IntZoom) {String url =Maketileimageurl (POS, zoom, LANGUAGESTR);ReturnGettileimageusinghttp (URL); }String Maketileimageurl (Gpoint pos,int zoom,StringLanguage) {//http://webrd04.is.autonavi.com/appmaptile?x=5&y=2&z=3&lang=zh_cn&size=1&scale=1 &style=7 string url = string. Format (Urlformat, Pos. X, Pos. Y, zoom); Console.WriteLine ("URL:" + URL); return URL;} static readonly string urlformat = "http://webrd04.is.autonavi.com/appmaptile?x={0}&y= {1}&z={2}&lang=zh_cn&size=1&scale=1&style=7";}
Original link: http://www.cnblogs.com/enjoyeclipse/archive/2013/01/27/2859029.html
(turn) deep understanding of the strongest desktop map control gmap.net---great map