Go Net Framework Guide Bee Map Development Example

Source: Internet
Author: User

From:http://www.2cto.com/kf/201207/140421.html

The Guide Bee map also provides support for the. Net Framework platform to develop desktop map applications, and because of the cross-platform features of Mono C #, map applications developed using Visual Studio and the Mono Guide Bee Map Development package can run on Windows, LUnix, Unix,mac OS and other platforms. Developing desktop applications is much easier than developing mobile apps, with more screen and memory than mobile platforms.
The following is a simple application that introduces the development of the. Net Framework Guide Bee map. Examples such as the following

Set up the Guide Bee Map Development Kit license

Lead Bee Development Package license is divided into two parts, one for the license file Guidebee.lic, the other for the license file corresponding to the registration code, to be initialized before the program runs

//set the map licence info. Licencemanager Licencemanager =licencemanager.getinstance ();Long[] keys =New[]{ -0x64fa2841ac936ab3l,0x492e8e7bf7876c44l, -0X3BB9B3E2A8E4C94DL,      0x224a4785c48a8eb3l,0x3a36fc72ad775a85l, -0X93B87A82371B0DDL, }; Licencemanager.addlicence ("guidebeemap_dotnet", keys); //set the map licence info.Licencemanager Licencemanager =licencemanager.getinstance ();Long[] keys =New[]{ -0x64fa2841ac936ab3l,0x492e8e7bf7876c44l, -0X3BB9B3E2A8E4C94DL,    0x224a4785c48a8eb3l,0x3a36fc72ad775a85l, -0X93B87A82371B0DDL,};licencemanager.addlicence ("guidebeemap_dotnet", keys);

setting up the. Net Framework platform-related graphics system implementation The Guide Bee Map Development package, in the design as far as possible platform-independent, will be some platform-related parts, shape system in the form of interface definition, such as ifont,igraphics,abstractgraphicsfactory,iimage. This enables the application of the same library to different platforms when applied to specific platforms, with platform-related implementations. These platform implementations are provided in source code, such as the Java SE platform, which provides the javasefont,javasegraphics,javasegraphicsfactory and Javaseimage class definitions, which can be found in the Guide Bee Map API Overview.

Initializing map objects and setting service callback functions

//Optional, get the tile URL from server. Maptype.updatemaptileurl (); Maplayer.setabstractgraphicsfactory (Netgraphicsfactory.getinstance ()); Mapconfiguration.setparameter (Mapconfiguration.workerthreadnumber, +); _mapimage= Maplayer.getabstractgraphicsfactory (). CreateImage (768,768); _mapgraphics=_mapimage.getgraphics (); _maptiledownloadmanager=NewMaptiledownloadmanager ( This); _rastermap=NewRastermap (2048,2048, _maptype, _maptiledownloadmanager); //_rastermap.setcurrentmapservice (Digitalmapservice.cloudmademapservice); //digitalmapservice.getsearchoptions ().  LanguageID = "ZH-CN"; _rastermap.setscreensize (768,768); _maptiledownloadmanager.start (); _rastermap.setmapdrawinglistener ( This); _rastermap.setgeocodinglistener ( This); _rastermap.setroutinglistener ( This); //Optional, get the tile URL from server.Maptype.updatemaptileurl (); Maplayer.setabstractgraphicsfactory (Netgraphicsfactory.getinstance ()); Mapconfiguration.setparameter (Mapconfiguration.workerthreadnumber, +); _mapimage= Maplayer.getabstractgraphicsfactory (). CreateImage (768,768); _mapgraphics=_mapimage.getgraphics (); _maptiledownloadmanager=NewMaptiledownloadmanager ( This); _rastermap=NewRastermap (2048,2048, _maptype, _maptiledownloadmanager);//_rastermap.setcurrentmapservice (digitalmapservice.cloudmademapservice);//digitalmapservice.getsearchoptions (). LanguageID = "ZH-CN";_rastermap.setscreensize (768,768); _maptiledownloadmanager.start (); _rastermap.setmapdrawinglistener ( This); _rastermap.setgeocodinglistener ( This); _rastermap.setroutinglistener ( This);
The above code sets the number of map worker threads to 16, generally increasing the number of payroll threads can improve the download and response speed of the map. Create a Map object to set the display area (screen) size. In addition, map services such as query addresses, get paths are asynchronous, by setting callback functions such as Setroutinglistener,setgeocodinglistener,setreversegeocodinglistener to notify the application. Set Map center and map types
var New GEOLATLNG (-31.948275115.857562varnew geolatlng (-31.948275115.857562, _rastermap.getmaptype ());
The above code sets the center of the map at 32.0616667, 118.7777778, the map type is Bing China map, the zoom level is 4, the Guide bee interior supports more than 20 kinds of map types, and supports custom map types.

Map Zoom

Rastermap's zoomin,zoomout is used to zoom in and out of the map, Setzoom can set the map level.

Map panning

Rastermap has two ways to pan the map, panto moves the map to the specified latitude and longitude coordinates, pandirection (dx,dy) pans the map from its current position dx,dy pixels. The following example can pan the map above, below, left, and right.

Address Query

An address query (or address code) converts an imported place name (such as Nanjing Forestry University) into a corresponding latitude and longitude coordinate and then displays it on the map.
All map services are called asynchronously, before calling Rastermap.getlocation (address). You need to set the callback function to return the result Rastermap.setgeocodinglistener, the callback function interface is defined as Igeocodinglistener. The callback method is public void-done (String query,mappoint[] result), and Reusult is an array of query results if the query result is not empty. Example moves the map to the first query result.
For the MAPABC map service, you can also specify a city code, such as Nanjing Code 25.
public void getLocation (int citycode,string query, Igeocodinglistener listener);

Path query

The path can be queried through the Rastermap getdirection () method, similar to the query address, and the result of the path query is also notified to the application via a callback function, and the following example returns the path from Nanjing to Beijing. The returned results are stored in mapdirection, and Mapdirection contains the details of the path, including each step of the path, length, time, direction, and so on.

Map Service can choose to use Google Maps service, Cloudmade Map service, in China may also choose MAPABC Map Service, the default use of Google Maps services.
Getdirections () has three overloaded functions, in which the text is described in the example. The above example takes the form of From:address1 To:address2, and the Cloudmade map service and MAPABC map service must use longitude 1, latitude 1, longitude 2, Latitude 2, and format.
To avoid confusion, you can use the following format.
public void Getdirection (geolatlng[] waypoints, Iroutinglistener listener);
Where waypoints is the way point coordinate array latitude and longitude value, can support multi-point path query.
In addition to the MAPABC map service, you can also specify a city code, such as Nanjing Code 25.
public void getdirection (int citycode,string query, Iroutinglistener listener);

Local query

Local queries can be queried for areas of interest, such as hotels, post offices, etc. within a given area. Its usage and address queries are very similar.
Local Query method public void Getlocations (String address,int start,geolatlng center,geobounds bound, Igeocodinglistener listener) ;
Specify the center point and query area. A local query can return results multiple times, start is the starting order of the query results, each return result is defined in searchoptions, and the default returns 4 each time.

Select Map Service

The Guide Bee Map service uses the Google Maps service by default, but you can also choose a different map service, for example, when Google services is offline, you can choose MAPABC's Map service, but also note that the Chinese map is offset. If you want to use a non-offset map of China, one is to use the map offset correction algorithm, the other is using the Cloudmade map service.
As mentioned above, the Guide Bee Map Development package Designs The map picture display and the map service two parts to be relatively independent two parts, the Google China map picture, Bing China map picture, mapabc China map picture is has the offset map picture, Cloudmade (Openstreet) China map picture is non-offset. And Google China Map Service, MAPABC China Map Service is offset, Cloudmade map service is non-offset. So when you choose a map type and a map service type, either you choose to have an offset, or you choose no offset. Otherwise, the map does not match when the path or address is displayed.

The following list is a valid combination:

Map type (maptype) Map service type (digitalmapservice)
Googlechina Google_map_service
Microsoftchina Google_map_service
Mapabcchina Google_map_service
OPENSTREETMAP Cloudmade_map_service
Googlechina Mapabc_map_service
Microsoftchina Mapabc_map_service
Mapabcchina Mapabc_map_service

Address anti-coding

Address anti-coding is through the latitude to query the corresponding place name,

Note When using the string latitude and longitude format, the latitude is in front, longitude is behind, if reversed, then the returned place name or can be empty or both run to the foreign country. The result is also an array, usually to the first result, followed by a larger area or a place with a relatively long distance.

. Net Framework

Help document Download
. Net Framework Guide Bee map Development Library Download
. Net Framework Guide Bee map Development Sample Download
GTK mono.net Framework Guide Bee map Development Sample Download
Guide to the development of bee map download

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.