Java ME guide bee map development example: local query

Source: Internet
Author: User

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

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.