The Guide bee map is also available. net Framework platform support allows you to develop table map applications. Thanks to the cross-platform features of Mono C #, map applications developed using Visual Studio and Mono web bee map can run on Windows, Lunix, unix, Mac OS, and other platforms. Developing desktop applications is much easier than developing mobile applications, and the screen and memory are much wider than those of mobile platforms.
The following uses a simple application to introduce the development of. Net Framework web tracking bee map. Example:
Set the License of the Web tracking bee map development kit
The License of the lead bee Development Kit is divided into two parts: one is the License file guidebee. lic, and the other is the registration code corresponding to the License file, which must be initialized before the program runs.
[Csharp]
// Set the map licence info.
LicenceManager licenceManager = LicenceManager. GetInstance ();
Long [] keys = new [] {-0x64fa2841ac936ab3L, 0x0000e8e7bf7876c44l,-0x3bb9b3e2a8e4c94dL,
0x224a4785c48a8eb3L, 0x3a36fc72ad775a85L,-0x93b87a82371b0ddL ,};
LicenceManager. AddLicence ("GuidebeeMap_DotNet", keys );
// Set the map licence info.
LicenceManager licenceManager = LicenceManager. GetInstance ();
Long [] keys = new [] {-0x64fa2841ac936ab3L, 0x0000e8e7bf7876c44l,-0x3bb9b3e2a8e4c94dL,
0x224a4785c48a8eb3L, 0x3a36fc72ad775a85L,-0x93b87a82371b0ddL ,};
LicenceManager. AddLicence ("GuidebeeMap_DotNet", keys); set the implementation of the. Net Framework Platform Graphics System
The Guide bee map development kit is designed with platform independence as much as possible. It defines some platform-related parts and shapes in the form of interfaces, such as IFont, IGraphics, AbstractGraphicsFactory, and IImage. In this way, the same database can be applied to different platforms by adding platform-related implementations to the specific platform. The implementation of these platforms is provided by source code. For example, on the Java SE platform, JavaSEFont, JavaSEGraphics, JavaSEGraphicsFactory, and JavaSEImage class definitions are provided. For more information, see overview of the pilot bee map API.
Initialize map objects and set service callback Functions
[Csharp]
// Optional, get the tile url from server.
MapType. UpdateMapTileUrl ();
MapLayer. SetAbstractGraphicsFactory (NETGraphicsFactory. GetInstance ());
MapConfiguration. SetParameter (MapConfiguration. WorkerThreadNumber, 32 );
_ MapImage = MapLayer. GetAbstractGraphicsFactory (). CreateImage (768,768 );
_ MapGraphics = _ mapImage. GetGraphics ();
_ MapTileDownloadManager = new MapTileDownloadManager (this );
_ RasterMap = new RasterMap (2048,204 8, _ 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, 32 );
_ MapImage = MapLayer. GetAbstractGraphicsFactory (). CreateImage (768,768 );
_ MapGraphics = _ mapImage. GetGraphics ();
_ MapTileDownloadManager = new MapTileDownloadManager (this );
_ RasterMap = new RasterMap (2048,204 8, _ 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 Code above sets the number of map worker threads to 16. Generally, increasing the number of worker threads can speed up map download and response.
Create a map object and set the display area (screen) size. In addition, the map service uses asynchronous methods to obtain paths such as query addresses. By setting callback functions such as setRoutingListener, setGeocodingListener, and setReverseGeocodingListener, the map service notifies the application.
Set map center and map type
[Csharp] view plaincopyprint?
Var center = new GeoLatLng (-31.948275, 115.857562 );
_ RasterMap. SetCenter (center, 15, _ rasterMap. GetMapType ());
Var center = new GeoLatLng (-31.948275, 115.857562 );
_ RasterMap. setCenter (center, 15, _ rasterMap. getMapType (); the preceding Code sets the map center to 32.0616667 and 118.7777778. The map type is Bing China map, and the zoom level is 4. The web bees support more than 20 map types, and supports custom map types.
Map Scaling
The ZoomIn and ZoomOut of RasterMap are used to zoom in and out the map. setZoom can be used to set the map level.
Map Translation
RasterMap can be used to translate a map. panTo moves the map to the coordinates of the specified longitude and latitude. panDirection (dx, dy) translates the map into dx and dy pixels from the current position. In the following example, the map can be moved up, down, left, and right.
Address Query
Address query (or address code) converts the entered Place Name (such as Nanjing Forestry University) to the corresponding latitude and longitude coordinates and then displays them on the map.
All map services are called asynchronously. Before calling RasterMap. getLocation (address), you must set the callback function RasterMap. setGeocodingListener for returning results. The callback function interface is defined as IGeocodingListener. The callback method is public void done (String query, MapPoint [] result). If the query result is not empty, reusult is the array of the query result. In this example, the map is forwarded to the first query result.
For the MapAbc map service, you can also specify the city code, for example, Nanjing code is 25.
Public void getLocation (int citycode, String query, IGeocodingListener listener );
Path Query
You can use the getDirection () method of RasterMap to query the path. Similar to the query address, the path query result notifies the application through the callback function, the following example returns the path from Nanjing to Beijing. The returned results are stored in MapDirection. MapDirection contains detailed information about the path, including each step, length, time, and direction of the path.
You can use the Google map service and CloudMade map service. You may also choose the MapAbc map service in China. The Google map service is used by default.
GetDirections () has three overload functions. In this example, the text description is used. The preceding example uses the from: address1 to: address2 format. The CloudMade and MapAbc map services must adopt the 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 );
Waypoints is the latitude and longitude value of the path coordinate array, and supports multi-point path query.
In addition, for the MapAbc map service, you can also specify the city code, for example, Nanjing code is 25.
Public void getDirection (int citycode, String query, IRoutingListener listener );
Local Query
Local query can be used to query areas of interest to users such as hotels and post offices in a specified region. Its usage is similar to address query.
Local query method public void getLocations (String address, int start, GeoLatLng center, GeoBounds bound, IGeocodingListener listener );
Specify the central point and query area. The local query can return results multiple times. start indicates the Starting sequence of the query results. Each returned result is defined in SearchOptions. Four results are returned each time by default.
Select map service
Google map is used by default in the Web tracking bee map service, but you can also choose other map services. For example, when Google is offline, you can choose the map service of MapAbc, note that there is an offset on the map of China. If you want to use a map of China without offset, use the map offset correction algorithm, and use the CloudMade map service.
As mentioned above, the Guide bee map development kit designs map image display and map service in two relatively independent parts: Google China map image and Bing China map image, the MapAbc map of China is a map image with an offset, while the CloudMade (OpenStreet) map of China is a map image without an offset. In the Google China Map Service, the MapAbc China Map Service has an offset while the CloudMade map service does not. Therefore, when selecting the map type and map service type, either an offset or no offset is selected. Otherwise, the map does not match when the path or address is displayed.
The following list is a valid combination:
Map 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-Encoding
Address anti-encoding is used to query the corresponding place names through longitude and latitude,
Note that when the string latitude and longitude format is used, the latitude is in the front, and the longitude is in the back. If the longitude is reversed, the returned place names may be empty or all of them will be transferred to a foreign country. The result is also an array, generally to the first result, followed by a larger area or a relatively distant place name.
. Net Framework
Help Document Download
. Net Framework guide map development library download
Download the. Net Framework web tracking map development example
Download the GTK Mono. Net Framework web guide map development example
Guide to map development
On Mac OS, if Mono GTK is used, the following error may occur.
The sing (Graphics g = Gtk. DotNet. Graphics. FromDrawable (area. GdkWindow) may throws
System. EntryPointNotFoundException: gdk_x11_drawable_get_xdisplay
A temporary solution is to use bmp files. The official solution is to use the Cario graphics system to implement GTKImage, GTKFont, GTKGraphics, and GTKGraphicsFactory.
[Csharp]
Protected virtual void OnPicMapCanvasExposeEvent (object o,
Gtk. ExposeEventArgs args)
{
DrawingArea area = (DrawingArea) o;
/* Using (Graphics g = Gtk. DotNet. Graphics. FromDrawable (area. GdkWindow )){
G. DrawImage (Bitmap) _ mapImage. GetNativeImage (), 0, 0 );
}*/
_ RasterMap. Paint (_ mapGraphics );
DrawImage (area, (Bitmap) _ mapImage. GetNativeImage ());
}
Private void DrawImage (DrawingArea area, System. Drawing. Image image ){
Try {
String filename = "dummy.png ";
Image. Save (filename, ImageFormat. Png );
Pixbuf pixbuf = new Pixbuf (filename );
Area. GdkWindow. DrawPixbuf (area. Style. WhiteGC,
Pixbuf, 0, 0, 0, pixbuf. Width, pixbuf. Height, RgbDither. None, 0, 0 );
} Catch (Exception e ){
Console. WriteLine (e. Message );
}
}
Protected virtual void OnPicMapCanvasExposeEvent (object o,
Gtk. ExposeEventArgs args)
{
DrawingArea area = (DrawingArea) o;
/* Using (Graphics g = Gtk. DotNet. Graphics. FromDrawable (area. GdkWindow )){
G. DrawImage (Bitmap) _ mapImage. GetNativeImage (), 0, 0 );
}*/
_ RasterMap. Paint (_ mapGraphics );
DrawImage (area, (Bitmap) _ mapImage. GetNativeImage ());
}
Private void DrawImage (DrawingArea area, System. Drawing. Image image ){
Try {
String filename = "dummy.png ";
Image. Save (filename, ImageFormat. Png );
Pixbuf pixbuf = new Pixbuf (filename );
Area. GdkWindow. DrawPixbuf (area. Style. WhiteGC,
Pixbuf, 0, 0, 0, pixbuf. Width, pixbuf. Height, RgbDither. None, 0, 0 );
} Catch (Exception e ){
Console. WriteLine (e. Message );
}
}
Author: mapdigit