android - 如何显示选项取决于地区谷歌地图
问题描述
我正在对 Taxi android 应用程序进行一些修改,我想知道如何根据地图或城市上的区域显示Car Type 。- (坐标)
例如:在纽约,我有这些选项(Mini、SUV、miniVan、Limousine),每个选项都有特价。
但是在新球衣中,我只有两个价格不同的选择(Mini,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();
}`
推荐阅读
- java - Mongodb Java驱动程序将数组插入集合
- python - 迭代地将字典转换为一组全局变量
- android - 关于跨多个活动重用工具栏的问题
- jbpm - 是否无法从 JBPM 中的脚本任务设置流程变量?
- unity3d - 如何使用 Unity 中的按钮切换/更改前后 Vuforia AR 摄像头?
- firebase - 可以从 Firestore 快照 Flutter 中获取元数据吗?
- swift - 如何在 MacOS 中正确显示 xib 文件的模态视图?
- microsoft-graph-api - 使用 Microsoft Flow 创建新的 Planner
- python - 密码重置链接重定向到解释域页面
- python - Python 产生:OSError: [WinError 193] %1 不是有效的 Win32 应用程序