我正在使用api搜索宾夕法尼亚州的Easton。发送到mapquest的网址如下所示:
http://www.mapquestapi.com/geocoding/v1/address?key=your_key_here&location=Easton,PA&outFormat=xml&maxresults=1
结果是这些(即使我有maxresults = 1)
<lat>40.689353</lat> <lng>-75.216698</lng>
和
<lat>41.127201</lat> <lng>-79.5411</lng>
我在Clarion County找不到Easton。知道为什么它会像这样工作,我怎么能避免这些类型的情况呢?
谢谢你的downvote,真的值得拥有!
答案 0 :(得分:0)
我从MapQuest得到了答案。看起来参数名称区分大小写。
不好:
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes final int tabId) {
if (tabId == R.id.tab_destiantion) {
Intent desintent = new Intent(MainActivity.this, DestinationList.class);
startActivity(desintent);
}else if (tabId == R.id.tab_home) {
Toast.makeText(getBaseContext(),"Beranda",Toast.LENGTH_SHORT).show();
}else if(tabId == R.id.tab_counter){
final AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
View mView = getLayoutInflater().inflate(R.layout.activity_tipebus, null);
mBuilder.setTitle("Tipe Bus yang digunakan");
final Spinner mSpinner = (Spinner) mView.findViewById(R.id.pilih_spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item,
getResources().getStringArray(R.array.Tipe_Bus));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(adapter);
mBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(mSpinner.getSelectedItem().toString().equalsIgnoreCase("Medium Bus")){
startActivity(new Intent(MainActivity.this, MediumBus.class));
}else if (mSpinner.getSelectedItem().toString().equalsIgnoreCase("Big Bus")){
startActivity(new Intent(MainActivity.this, BigBus.class));
}else if (mSpinner.getSelectedItem().toString().equalsIgnoreCase("ELF 12")){
startActivity(new Intent(MainActivity.this, Elf12Seat.class));
}else if (mSpinner.getSelectedItem().toString().equalsIgnoreCase("ELF 16")){
startActivity(new Intent(MainActivity.this, Elf16Seat.class));
}
}
});
mBuilder.setNegativeButton("Batal", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
dialog.dismiss();
}
});
mBuilder.setView(mView);
AlertDialog dialog = mBuilder.create();
dialog.show();
}else if (tabId == R.id.tab_broadcast){
final AlertDialog.Builder tBuilder = new AlertDialog.Builder(MainActivity.this);
final View tView = getLayoutInflater().inflate(R.layout.activity_message_passenger,null);
final EditText editText = (EditText) tView.findViewById(R.id.textHere);
tBuilder.setTitle("Pesan Anda");
tBuilder.setPositiveButton("SEND", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PackageManager pm=getPackageManager();
try {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = editText.getText().toString();
//the above (textHere) From my CustomLayout Edit TEXT
PackageInfo info = pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
//Check if package exists or not. If not then code
//in catch block will be called
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, "Share with"));
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(getBaseContext(), "WhatsApp not Installed", Toast.LENGTH_SHORT)
.show();
}
}
});
tBuilder.setNegativeButton("Batal", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
dialog.dismiss();
}
});
tBuilder.setView(tView);
AlertDialog dialog = tBuilder.create();
dialog.show();
}else if (tabId == R.id.tab_note){
String note = "";
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, note);
sendIntent.setType("text/plain");
Intent chooser = Intent.createChooser(sendIntent, "Catatan Perjalanan");
if (sendIntent.resolveActivity(getPackageManager()) != null){
startActivity(chooser);
}
}
}
});
好:
http://www.mapquestapi.com/geocoding/v1/address?key=your_key_here&location=Easton,PA&outFormat=xml&maxresults=1