我正在尝试使用反向地理编码检索特定GeoCoordinate的地址,但是我在执行反向GeoCode请求时遇到了一些错误。我收到错误:400错误请求。这是我的完整代码:
public class Address_Service extends AppCompatActivity {
String Location1,Address;
double Lat,Lng;
private ListView list;
private boolean isMapInitialized = false;
//LIST OF ARRAY STRINGS WHICH WILL SERVE AS LIST ITEMS
ArrayList<String> listItems=new ArrayList<String>();
//DEFINING A STRING ADAPTER WHICH WILL HANDLE THE DATA OF THE LISTVIEW
ArrayAdapter<String> adapter;
private BroadcastReceiver BUS_COD=new BroadcastReceiver() { //this receiver recieves new location from Database service
@Override
public void onReceive(Context context, Intent intent) {
Location1=intent.getStringExtra("BUS_LOC");
Lat = Double.valueOf(Location1.substring(0, 9));//extracting latitude
Lng = Double.valueOf(Location1.substring(10, Location1.length()));//extracting longitude
Log.e("Got new loc from FB",Location1);
get_address();
}
};
public void get_address()
{
ReverseGeocodeRequest2 request = new ReverseGeocodeRequest2(new GeoCoordinate(Lat,Lng,0.0));
request.execute(new ResultListener<com.here.android.mpa.search.Location>() {
@Override
public void onCompleted(com.here.android.mpa.search.Location location, ErrorCode errorCode) {
if(errorCode!=ErrorCode.NONE){
Log.e("Error",errocode.getmessage());
}else{
if (location != null) {
Address = location.getAddress().toString();
listItems.add(Address_of_Bus);
}
}
}
});
}
@Override
protected void onCreate( Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reverse_geocode_layout);
list=(ListView) (findViewById(R.id.listView));
adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,listItems);
list.setAdapter(adapter);
initialize();
}
public void initialize() {
MapEngine mapEngine= MapEngine.getInstance();
mapEngine.init(this, new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == OnEngineInitListener.Error.NONE) {
IntentFilter intentFilter=new IntentFilter();
intentFilter.addAction("GOT_NEW_L_M");
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(BUS_COD,intentFilter);
Intent intent=new Intent(Address_Service.this,Database_service.class);
startService(intent);
isMapInitialized = true;
} else {
Log.e("Initialization", "ERROR: Cannot initialize Map Fragment");
}
}
});
}
@Override
protected void onDestroy() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(BUS_COD);
this.stopService(new Intent(Address_Service.this,Database_service.class));
super.onDestroy();
}
@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(BUS_COD);
super.onPause();
}
@Override
protected void onResume()
{
IntentFilter intentFilter=new IntentFilter();
intentFilter.addAction("GOT_NEW_L_M");
LocalBroadcastManager.getInstance(this).registerReceiver(BUS_COD,intentFilter);
super.onResume();
}
}
这是带有错误的Logcat:
E/NativeCrypto: ssl=0x5466b490 cert_verify_callback calling
verifyCertificateChain authMethod=ECDHE_RSA
09-27 17:24:35.352 3554-3770/
E/NETWORK: Request:
https://places.hybrid.api.here.com/places/v1/meta/offline?
app_id=HxZCZftG2X5aQ0Bhlg1W&app_code=TF3wLtVoLtqhmTi1FOcSaw Error: 400 Bad
Request
我在API19上运行的真实设备上使用它。我实际上用通过反向地理编码接收的地址填充listView。
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<ListView
android:layout_width="match_parent"
android:layout_height="430dp"
android:layout_marginTop="30dp"
android:layout_gravity="center"
android:id="@+id/listView" />
</LinearLayout>
答案 0 :(得分:0)
HERE提供了不同的产品,这些产品还涵盖了特定的特性和功能:
转发地理编码 反向地理编码 多重反向地理编码 批量地理编码 地理编码自动完成 地方(搜索)
请在此处查看概述:https://developer.here.com/products/geocoding-and-search