Example of developing a map of Blackberry web bees: address anti-Encoding

Source: Internet
Author: User

The address anti-code is used to query the corresponding place names through latitude and longitude. The following example shows the place names corresponding to latitude and longitude 118.777802 and 32.061699. The result is "41, yuanshengxiang, Gulou District, Nanjing City, Jiangsu Province, China ".

[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. IReverseGeocodingListener;
Import com. pstreets. gisengine. demo. MapDemoRIM;
Import net. rim. device. api. ui. component. Menu;
Import net. rim. device. api. ui. MenuItem;

// [-------------------------------- Main class ----------------------------------]
Public class MapReverseGeocodingRIM extends MapDemoRIM implements
IReverseGeocodingListener {

/**
* 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.
MapReverseGeocodingRIM theApp = new MapReverseGeocodingRIM ();
TheApp. enterEventDispatcher ();
}

Private MenuItem mapFindAddressMenuItem = new MenuItem ("Find Address", 0, 0 ){
Public void run (){
Map. getReverseLocations ("32.061699, 118.777802 ");
}
};

Public MapReverseGeocodingRIM (){

Init ();
PushScreen (canvas );
Map. setReverseGeocodingListener (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. IReverseGeocodingListener;
Import com. pstreets. gisengine. demo. MapDemoRIM;
Import net. rim. device. api. ui. component. Menu;
Import net. rim. device. api. ui. MenuItem;
 
// [-------------------------------- Main class ----------------------------------]
Public class MapReverseGeocodingRIM extends MapDemoRIM implements
IReverseGeocodingListener {
 
/**
* 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.
MapReverseGeocodingRIM theApp = new MapReverseGeocodingRIM ();
TheApp. enterEventDispatcher ();
}

Private MenuItem mapFindAddressMenuItem = new MenuItem ("Find Address", 0, 0 ){
Public void run (){
Map. getReverseLocations ("32.061699, 118.777802 ");
}
};
 
Public MapReverseGeocodingRIM (){
 
Init ();
PushScreen (canvas );
Map. setReverseGeocodingListener (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 );
}
}
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.

Author: mapdigit
 

Related Article

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.