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;
Import com. mapdigit. gis. DigitalMap;
Import com. mapdigit. gis. MapPoint;
Import com. mapdigit. gis. geometry. GeoLatLng;
Import com. mapdigit. gis. service. IReverseGeocodingListener;
Import com. mapdigit. gis. service. IpAddressLocation;
Import com. pstreets. gisengine. R;
Import com. pstreets. gisengine. SharedMapInstance;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. view. Menu;
Import android. view. MenuInflater;
Import android. view. MenuItem;
Public class MapReverseGeocoding extends Activity implements
IReverseGeocodingListener {
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
}
@ Override
Public void onStart (){
Super. onStart ();
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
SharedMapInstance. map. setCenter (center, 15,
Com. mapdigit. gis. raster. MapType. MICROSOFTCHINA );
SharedMapInstance. map. setReverseGeocodingListener (this );
}
@ Override
Public boolean onCreateOptionsMenu (Menu menu ){
MenuInflater inflater = getMenuInflater ();
Inflater. inflate (R. menu. mapgeocoding_menu, menu );
Return true;
}
@ Override
Public boolean onOptionsItemSelected (MenuItem item ){
// Handle item selection
Switch (item. getItemId ()){
Case R. id. findaddress:
SharedMapInstance. map. getReverseLocations ("32.061699, 118.777802 ");
Return true;
Default:
Return super. onOptionsItemSelected (item );
}
}
Www.2cto.com
@ Override
Public void done (String arg0, MapPoint [] result ){
If (result! = Null ){
SharedMapInstance. map. panTo (result [0]. getPoint ());
}
}
@ Override
Public void readProgress (int bytes, int total ){
}
}
Package com. pstreets. gisengine. demo;
Import com. mapdigit. gis. DigitalMap;
Import com. mapdigit. gis. MapPoint;
Import com. mapdigit. gis. geometry. GeoLatLng;
Import com. mapdigit. gis. service. IReverseGeocodingListener;
Import com. mapdigit. gis. service. IpAddressLocation;
Import com. pstreets. gisengine. R;
Import com. pstreets. gisengine. SharedMapInstance;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. view. Menu;
Import android. view. MenuInflater;
Import android. view. MenuItem;
Public class MapReverseGeocoding extends Activity implements
IReverseGeocodingListener {
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
}
@ Override
Public void onStart (){
Super. onStart ();
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
SharedMapInstance. map. setCenter (center, 15,
Com. mapdigit. gis. raster. MapType. MICROSOFTCHINA );
SharedMapInstance. map. setReverseGeocodingListener (this );
}
@ Override
Public boolean onCreateOptionsMenu (Menu menu ){
MenuInflater inflater = getMenuInflater ();
Inflater. inflate (R. menu. mapgeocoding_menu, menu );
Return true;
}
@ Override
Public boolean onOptionsItemSelected (MenuItem item ){
// Handle item selection
Switch (item. getItemId ()){
Case R. id. findaddress:
SharedMapInstance. map. getReverseLocations ("32.061699, 118.777802 ");
Return true;
Default:
Return super. onOptionsItemSelected (item );
}
}
@ Override
Public void done (String arg0, MapPoint [] result ){
If (result! = Null ){
SharedMapInstance. map. panTo (result [0]. getPoint ());
}
}
@ Override
Public void readProgress (int bytes, int total ){
}
}
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