The API also provides address query, path query, local search, IP address query, and address anti-encoding (querying place names through longitude and latitude. 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.
[Java]
// ----------------------------------- PACKAGE ------------------------------------
Package com. pstreets. gisengine. demo. rim;
// ------------------------------------- IMPORTS ------------------------------------
Import com. mapdigit. gis. MapPoint;
Import com. mapdigit. gis. geometry. GeoLatLng;
Import com. mapdigit. gis. raster. MapType;
Import com. mapdigit. gis. service. IGeocodingListener;
Import com. pstreets. gisengine. demo. MapDemoRIM;
Import net. rim. device. api. ui. component. Menu;
Import net. rim. device. api. ui. MenuItem;
// [-------------------------------- Main class ----------------------------------]
/**
* Map pan demo for Guidebee Map API on MIDP platform.
* <Hr> <B>©Copyright 2011 Guidebee, Inc. All Rights Reserved. </B>
* @ Version 1.00, 09/02/11
* @ Author Guidebee Pty Ltd.
*/
Public class MapGeocodingRIM extends MapDemoRIM implements IGeocodingListener {
/**
* Entry point for application www.2cto.com
* @ 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.
MapGeocodingRIM theApp = new MapGeocodingRIM ();
TheApp. enterEventDispatcher ();
}
Private MenuItem mapFindAddressMenuItem = new MenuItem ("Find Address", 0, 0 ){
Public void run (){
Map. getLocations ("Nanjing Forestry University ");
}
};
Public MapGeocodingRIM (){
Init ();
PushScreen (canvas );
Map. setGeocodingListener (this );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
}
Public void done (String arg0, MapPoint [] result ){
If (result! = Null ){
Map. panTo (result [0]. getPoint ());
}
}
Protected void createMenu (Menu menu, int instance ){
Menu. add (mapFindAddressMenuItem );
}
}
// ----------------------------------- PACKAGE ------------------------------------
Package com. pstreets. gisengine. demo. rim;
// ------------------------------------- IMPORTS ------------------------------------
Import com. mapdigit. gis. MapPoint;
Import com. mapdigit. gis. geometry. GeoLatLng;
Import com. mapdigit. gis. raster. MapType;
Import com. mapdigit. gis. service. IGeocodingListener;
Import com. pstreets. gisengine. demo. MapDemoRIM;
Import net. rim. device. api. ui. component. Menu;
Import net. rim. device. api. ui. MenuItem;
// [-------------------------------- Main class ----------------------------------]
/**
* Map pan demo for Guidebee Map API on MIDP platform.
* <Hr> <B>©Copyright 2011 Guidebee, Inc. All Rights Reserved. </B>
* @ Version 1.00, 09/02/11
* @ Author Guidebee Pty Ltd.
*/
Public class MapGeocodingRIM extends MapDemoRIM implements IGeocodingListener {
/**
* 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.
MapGeocodingRIM theApp = new MapGeocodingRIM ();
TheApp. enterEventDispatcher ();
}
Private MenuItem mapFindAddressMenuItem = new MenuItem ("Find Address", 0, 0 ){
Public void run (){
Map. getLocations ("Nanjing Forestry University ");
}
};
Public MapGeocodingRIM (){
Init ();
PushScreen (canvas );
Map. setGeocodingListener (this );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
}
Public void done (String arg0, MapPoint [] result ){
If (result! = Null ){
Map. panTo (result [0]. getPoint ());
}
}
Protected void createMenu (Menu menu, int instance ){
Menu. add (mapFindAddressMenuItem );
}
} All map services are called asynchronously. before getLocation (address), you need to set the callback function RasterMap for returning results. setGeocodingListener. 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.
Author: mapdigit