我正在为Taxi android应用程序做一些修改,我想知道如何根据地图或城市上的区域显示汽车类型。-(坐标(
例如:在纽约,我有这些选择(迷你,SUV,迷你面包车,豪华轿车(,每种都有特价。
但是在内瓦球衣,我只有两个选择(迷你,Suv(不同的价格(例如不像纽约(。
我该怎么做?
根据坐标可以找到城市
` try {
Geocoder geocoder;
String city=null;
List<Address> yourAddresses;
geocoder = new Geocoder(this, Locale.getDefault());
yourAddresses = geocoder.getFromLocation(yourLatitude, yourLongitude, 1);
final String yourAddress = yourAddresses.get(0).getAddressLine(0);
if (yourAddresses != null && yourAddresses.size() > 0) {
android.location.Address address = yourAddresses.get(0);
@SuppressWarnings("MismatchedQueryAndUpdateOfStringBuilder") StringBuilder sb = new StringBuilder();
for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
sb.append(address.getAddressLine(i)).append("n");
}
city = address.getLocality();
Log.d("city", "onCreate: "+city);
}
} catch (IOException e) {
e.printStackTrace();
}`