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.
[Java]
// ----------------------------------- PACKAGE ------------------------------------
Package com. pstreets. gisengine. demo. rim;
// ------------------------------------- IMPORTS ------------------------------------
Import com. mapdigit. gis. MapDirection;
Import com. mapdigit. gis. geometry. GeoLatLng;
Import com. mapdigit. gis. raster. MapType;
Import com. mapdigit. gis. service. IRoutingListener;
Import com. pstreets. gisengine. demo. MapDemoRIM;
Import net. rim. device. api. ui. component. Menu;
Import net. rim. device. api. ui. MenuItem;
// [-------------------------------- Main class ----------------------------------]
/**
* Map routing demo for Guidebee Map API on RIM platform.
* <Hr> <B>©Copyright 2011 Guidebee, Inc. All Rights Reserved. </B>
* @ Version 1.00, 10/02/11
* @ Author Guidebee Pty Ltd.
*/
Public class MapRoutingRIM extends MapDemoRIM implements IRoutingListener {
/**
* Entry point for application
* @ Param args Command line arguments (not used)
*/
Public static void main (String [] args)
{
// Create a new instance of the application and make the currently
// Running thread the application's event dispatch thread.
MapRoutingRIM theApp = new MapRoutingRIM ();
TheApp. enterEventDispatcher ();
}
Private MenuItem mapgetdiremenmenuitem = new MenuItem ("Get Direction", 0, 0 ){
Public void run (){
String name1 = "Nanjing ";
String name2 = "Beijing ";
Map. getDirections ("from:" + name1 + "to:" + name2 );
}
};
Public MapRoutingRIM (){
Init ();
PushScreen (canvas );
Map. setRoutingListener (this );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
}
Public void done (String arg0, MapDirection result ){
If (result! = Null ){
Map. setMapDirection (result );
Map. resize (result. getBound ());
Map. setZoom (5 );
}
}
Protected void createMenu (Menu menu, int instance ){
Menu. add (mapgetdiremenmenuitem );
}
}
// ----------------------------------- PACKAGE ------------------------------------
Package com. pstreets. gisengine. demo. rim;
// ------------------------------------- IMPORTS ------------------------------------
Import com. mapdigit. gis. MapDirection;
Import com. mapdigit. gis. geometry. GeoLatLng;
Import com. mapdigit. gis. raster. MapType;
Import com. mapdigit. gis. service. IRoutingListener;
Import com. pstreets. gisengine. demo. MapDemoRIM;
Import net. rim. device. api. ui. component. Menu;
Import net. rim. device. api. ui. MenuItem;
// [-------------------------------- Main class ----------------------------------]
/**
* Map routing demo for Guidebee Map API on RIM platform.
* <Hr> <B>©Copyright 2011 Guidebee, Inc. All Rights Reserved. </B>
* @ Version 1.00, 10/02/11
* @ Author Guidebee Pty Ltd.
*/
Public class MapRoutingRIM extends MapDemoRIM implements IRoutingListener {
/**
* Entry point for application
* @ Param args Command line arguments (not used)
*/
Public static void main (String [] args)
{
// Create a new instance of the application and make the currently
// Running thread the application's event dispatch thread.
MapRoutingRIM theApp = new MapRoutingRIM ();
TheApp. enterEventDispatcher ();
}
Private MenuItem mapgetdiremenmenuitem = new MenuItem ("Get Direction", 0, 0 ){
Public void run (){
String name1 = "Nanjing ";
String name2 = "Beijing ";
Map. getDirections ("from:" + name1 + "to:" + name2 );
}
};
Public MapRoutingRIM (){
Init ();
PushScreen (canvas );
Map. setRoutingListener (this );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
}
Public void done (String arg0, MapDirection result ){
If (result! = Null ){
Map. setMapDirection (result );
Map. resize (result. getBound ());
Map. setZoom (5); www.2cto.com
}
}
Protected void createMenu (Menu menu, int instance ){
Menu. add (mapgetdiremenmenuitem );
}
}
Author: mapdigit