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 com. pstreets. gisengine. demo. lwuit;
// ------------------------------------- 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. MapDemoLWUIT;
Import com. sun. lwuit. Command;
Import com. sun. lwuit. events. ActionEvent;
Public class MapReverseGeocodingLWUIT extends MapDemoLWUIT
Implements IReverseGeocodingListener {
Private Command mapFindAddressCommand;
Public void startApp (){
Init ();
Canvas. setTitle ("Map Reverse Geocoding ");
MapFindAddressCommand = new Command ("Find Address "){
Public void actionreceivmed (ActionEvent evt ){
Map. getReverseLocations ("32.061699, 118.777802 ");
}
};
Canvas. addCommand (mapFindAddressCommand );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
Map. setReverseGeocodingListener (this );
Canvas. show ();
}
Public void done (String arg0, MapPoint [] result ){
If (result! = Null ){
Map. panTo (result [0]. getPoint ());
}
}
}
Package com. pstreets. gisengine. demo. lwuit;
// ------------------------------------- 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. MapDemoLWUIT;
Import com. sun. lwuit. Command;
Import com. sun. lwuit. events. ActionEvent; www.2cto.com
Public class MapReverseGeocodingLWUIT extends MapDemoLWUIT
Implements IReverseGeocodingListener {
Private Command mapFindAddressCommand;
Public void startApp (){
Init ();
Canvas. setTitle ("Map Reverse Geocoding ");
MapFindAddressCommand = new Command ("Find Address "){
Public void actionreceivmed (ActionEvent evt ){
Map. getReverseLocations ("32.061699, 118.777802 ");
}
};
Canvas. addCommand (mapFindAddressCommand );
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
Map. setCenter (center, 13, MapType. MICROSOFTCHINA );
Map. setReverseGeocodingListener (this );
Canvas. show ();
}
Public void done (String arg0, MapPoint [] result ){
If (result! = Null ){
Map. panTo (result [0]. getPoint ());
}
}
}
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