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.
The following example queries the information of a hotel in a certain area in the central point of 32.0616667 and 118.7777778.
[Java]
// ----------------------------------- PACKAGE ------------------------------------
Package com. pstreets. gisengine. demo. midp;
// ------------------------------------- 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. MapDemoMIDP;
Import javax. microedition. lcdui. Command;
Import javax. microedition. lcdui. CommandListener;
Import javax. microedition. lcdui. Display;
Import javax. microedition. lcdui. Displayable;
// [-------------------------------- Main class ----------------------------------]
// ----------------------------------- REVISIONS ----------------------------------
// Date Name Tracking # Description
//------------------------------------------------------------------
// 28JAN2011 James Shen Initial Creation
//////////////////////////////////////// ////////////////////////////////////////
/**
* Map pan demo for Guidebee Map API on MIDP platform.
*/
Public class MapLocalSearchMIDP extends MapDemoMIDP implements CommandListener,
IGeocodingListener {
Private Command mapFindAddressCommand = new Command ("Find Address ",
Command. OK, 1 );
Public void startApp (){
Init ();
Canvas. addCommand (mapFindAddressCommand );
Map. setGeocodingListener (this );
Canvas. setCommandListener (this );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
Display. getDisplay (this). setCurrent (canvas );
}
Public void commandAction (Command c, Displayable d ){
If (c = mapFindAddressCommand ){
String name = "?? ";
GeoLatLng screenCenter = map. getScreenCenter ();
Map. getLocations (name, 0, screenCenter,
Map. getScreenBounds (screenCenter ));
}
}
Public void done (String query, MapPoint [] result ){
If (result! = Null ){
Map. panTo (result [0]. getPoint ());
For (int I = 0; I <result. length; I ++ ){
System. out. println (result [I]. objectNote );
}
}
}
}
// ----------------------------------- PACKAGE ------------------------------------
Package com. pstreets. gisengine. demo. midp;
// ------------------------------------- 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. MapDemoMIDP;
Import javax. microedition. lcdui. Command;
Import javax. microedition. lcdui. CommandListener;
Import javax. microedition. lcdui. Display;
Import javax. microedition. lcdui. Displayable;
// [-------------------------------- Main class ----------------------------------]
// ----------------------------------- REVISIONS ----------------------------------
// Date Name Tracking # Description
//------------------------------------------------------------------
// 28JAN2011 James Shen Initial Creation
//////////////////////////////////////// ////////////////////////////////////////
/**
* Map pan demo for Guidebee Map API on MIDP platform.
*/
Public class MapLocalSearchMIDP extends MapDemoMIDP implements CommandListener,
IGeocodingListener {
Private Command mapFindAddressCommand = new Command ("Find Address ",
Command. OK, 1 );
Public void startApp (){
Init ();
Canvas. addCommand (mapFindAddressCommand );
Map. setGeocodingListener (this );
Canvas. setCommandListener (this );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
Display. getDisplay (this). setCurrent (canvas );
}
Public void commandAction (Command c, Displayable d ){
If (c = mapFindAddressCommand ){
String name = "?? ";
GeoLatLng screenCenter = map. getScreenCenter ();
Map. getLocations (name, 0, screenCenter,
Map. getScreenBounds (screenCenter ));
}
}
Public void done (String query, MapPoint [] result ){
If (result! = Null ){
Map. panTo (result [0]. getPoint ());
For (int I = 0; I <result. length; I ++ ){
System. out. println (result [I]. objectNote );
}
}
}
}
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. Www.2cto.com
The returned results may be different.
"Jingli hotel 025-83310818 025-83310818212223 025-86636636"
"Celebrity hotels in cities 025-83123333 025-83123888"
"Nanjing Xuanwu hotel 025-83358888"
"Sofitel Galaxy Nanjing-Sofitel Nanjing Galaxy Hotel 025-83718888
Author: mapdigit