In-depth understanding of the strongest desktop map control gmap.net---First use

Source: Internet
Author: User

The previous article introduced the basic concepts of gmap.net and some demos, this chapter mainly describes how our code uses Gmap.net.

1. Download

http://greatmaps.codeplex.com/releases/view/20235

2. Compiling Gmap.net Project

3. Referencing in the project

My project is using WPF, so you need to reference gmap.net core and GMap.NET.WindowsPresentation two DLLs.

4. Gmapcontrol

1) Usercontrol.xaml Create a UserControl and refer to Gmapcontrolin UserControl, I set up maxzoom and Minzoom, It is also the largest scale scale bar supported by Gmap.net, as follows:

<UserControlx:class= "UICommon.View.Map.GMapTrack"xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"Xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"Xmlns:gmap= "Clr-namespace:gmap.net.windowspresentation;assembly=gmap.net.windowspresentation"Xmlns:map= "Clr-namespace:uicommon.view.map"x:name= "UserControl"><Grid><GroupBoxName= "Mapgroup"Margin= "0,0,50,0"Verticalcontentalignment= "Stretch"Horizontalcontentalignment= "Stretch"> <gmap: Gmapcontrol x:name= "Mainmap"  Maxzoom= " minzoom< Span style= "color: #0000ff;" >= "1" > </gmap: Gmapcontrol> </> </></ Usercontrol>          
5. Gmapcontrol Events

Set the event code, including mouse entry event MouseEnter, right mouse button event Mouserightbuttondown, mouse double-click event MouseDoubleClick.

Ontileloadstart and Ontileloadcomplete are like this: all maps are downloaded with a single picture downloaded and stitched together, and the picture here is called Tile. So

Ontileloadstart is the event that is triggered every time a picture starts loading, and Ontileloadcomplete is the event that fires every time each picture is loaded. Then you can show it in Ontileloadstart.

Loading or the progress bar is not going to make the user feel dead there, and Ontileloadcomplete can close the progress bar.

Public Gmaptrack ()        {            InitializeComponent ();            This . Mainmap.mouseenter + = mainmap_mouseenter;  
        This. Mainmap.mouserightbuttondown + = new Mousebuttoneventhandler (mainmap_mouserightbuttondown);            This. Mainmap.mousedoubleclick + = new Mousebuttoneventhandler (Mainmap_mousedoubleclick);
       This. Mainmap.ontileloadstart + = Mainmap_ontileloadstart;
This. Mainmap.ontileloadcomplete + =
New
}
6. Gmapcontrol Loaded Initialization

Position is the central location where the map is started by default, which I read from within the configuration file.

area refers to the entire region of the map, which can be filled out

Mode has three types, cacheonly (only from the cache), Serverandcache (Network + cache), serveronly (read only from the network)

Mapprovider is the source of the map, the default is OpenStreetMap, of course, can also make Bingmap, GoogleMap, about Baidu, Soso and other domestic map support will be introduced in the following chapters.

Dragbutton refers to whether you drag the map with the left or right mouse button

Zoom is the level of the current map display (1~24)

minzoom is the smallest level of support for maps, andmaxzoom is the largest level supported by the map.

                This. Mainmap.position =New POINTLATLNG (Double. Parse (configurationmanager.appsettings["Defaultlat"]),Double. Parse (configurationmanager.appsettings["Defaultlng"]));This. MainMap.MapProvider.Area =New RECTLATLNG (30.981178,105.351914,2.765142,4.120995);This. Mainmap.boundsofmap =New RECTLATLNG (30.981178, 105.351914, 2.765142, 4.120995this. MainMap.Manager.Mode = accessmode.cacheonly; this. Mainmap.mapprovider = Gmapproviders.openstreetmap; this. Mainmap.dragbutton = Mousebutton.left; this. Mainmap.zoom = 13this. Mainmap.minzoom = 8this. Mainmap.maxzoom = 24;           

Original link: http://www.cnblogs.com/enjoyeclipse/archive/2013/01/13/2858590.html

(turn) in-depth understanding of the strongest desktop map control gmap.net---First use

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.