if (-1 == NetworkUtil.getNetworkType(getApplicationContext())) {
NetworkUtil.noNetworkHint(getApplicationContext());
} else {
String textCity = etHistoryCity.getText().toString();
boolean isInputCity = textCity != null
&& textCity.trim().length() > 0;
if (isNear) {
// 周边搜索
Toast.makeText(
getApplicationContext(),
getResources().getString(R.string.poi_search_near)
- where, Toast.LENGTH_SHORT).show();
PoiNearbySearchOption poiOption = new PoiNearbySearchOption();
poiOption.keyword(where);
poiOption.location(centerLatLng);
poiOption.radius(15 * 1000 * 1000); // 检索半径,单位:m
poiOption.sortType(PoiSortType.distance_from_near_to_far); // 按距离排序
// poiOption.sortType(PoiSortType.comprehensive); // 按综合排序
poiOption.pageNum(0); // 分页编号
poiOption.pageCapacity(10); // 设置每页容量,默认为每页10条
try {
mPoiSearch.searchNearby(poiOption);
} catch (Exception e) {
e.printStackTrace();
}
} else {
if (!isInputCity) {
// 周边搜索
Toast.makeText(
getApplicationContext(),
getResources().getString(
R.string.poi_search_near)
- where, Toast.LENGTH_SHORT).show();
PoiNearbySearchOption poiOption = new PoiNearbySearchOption();
poiOption.keyword(where);
poiOption.location(centerLatLng);
poiOption.radius(15 * 1000 * 1000); // 检索半径,单位:m
poiOption
.sortType(PoiSortType.distance_from_near_to_far); // 按距离排序
// poiOption.sortType(PoiSortType.comprehensive); //
// 按综合排序
poiOption.pageNum(0); // 分页编号
poiOption.pageCapacity(10); // 设置每页容量,默认为每页10条
try {
mPoiSearch.searchNearby(poiOption);
} catch (Exception e) {
e.printStackTrace();
}
} else {
// 全国搜索
Toast.makeText(
getApplicationContext(),
getResources().getString(R.string.poi_in_city)
-
textCity
-
getResources().getString(
R.string.poi_search) + where,
Toast.LENGTH_SHORT).show();
PoiCitySearchOption poiOption = new PoiCitySearchOption();
poiOption.city(textCity);
poiOption.keyword(where);
poiOption.pageNum(0);
poiOption.pageCapacity(10);
mPoiSearch.searchInCity(poiOption);
}
// 存储搜索历史到数据库,周边不需要
int existId = naviDb.getNaviIdByKey(where);
if (existId != -1) {
naviDb.deleteNaviHistoryById(existId);
}
NaviHistory naviHistory = new NaviHistory(where, textCity);
naviDb.addNaviHistory(naviHistory);
naviHistoryAdapter.notifyDataSetChanged();
}
}
}
}
坐标系转化:
/**
-
startLatitude,startLongitude为bd09ll
-
bdLocStartAfter.getLongitude()和bdLocStartAfter.getLatitude()即为转化过的坐标系
-
BDLocation.BDLOCATION_BD09LL_TO_GCJ02表示从bd09ll转成gcj02坐标系
*/
BDLocation bdLocStartBefore = new BDLocation();
bdLocStartBefore.setLatitude(startLatitude);
bdLocStartBefore.setLongitude(startLongitude);
BDLocation bdLocStartAfter = LocationClient.getBDLocationInCoorType(
bdLocStartBefore, BDLocation.BDLOCATION_BD09LL_TO_GCJ02);
周边和收藏
在导航的基础上,实现了周边搜索和收藏的功能:
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

最后
愿你有一天,真爱自己,善待自己。
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!
得这些内容对你有帮助,可以扫码获取!!(备注:Android)**

最后
愿你有一天,真爱自己,善待自己。