Pony,仿支付宝到位动态加载marker效果
来源:互联网 发布:淘宝会员名怎么注册 编辑:程序博客网 时间:2024/05/20 03:43
使用到的知识点:
1:高德地图定位;
2:高德地图poi搜索;
3:动态监测地图中心位置的坐标;
4:添加marker
实现步骤:
1:在进入主界面的时候先进行定位的操作,为的就是显示的poi的信息是自己附近的poi的信息;
/** * 定位成功后回调函数 */@Overridepublic void onLocationChanged(AMapLocation amapLocation) {amapLocation.getAddress();if (mListener != null && amapLocation != null) {if (amapLocation != null && amapLocation.getErrorCode() == 0) {aMapLocationMessage = amapLocation;LatLng location = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude());if (!mFirstFix) {mFirstFix = true;addCircle(location, amapLocation.getAccuracy());// 添加定位精度圆addMarker(location);// 添加定位图标mSensorHelper.setCurrentMarker(mLocMarker);// 定位图标旋转aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 18));doSearchQuery(new LatLonPoint(location.longitude, location.latitude));} else {mCircle.setCenter(location);mCircle.setRadius(amapLocation.getAccuracy());mLocMarker.setPosition(location);}} else {String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();Log.i("AmapErr", errText);}}}
/** * 开始进行poi搜索 */protected void doSearchQuery(LatLonPoint lp) {currentPage = 0;
query = new PoiSearch.Query("公园", "", "");// 第一个参数表示搜索字符串,第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国)query.setPageSize(20);// 设置每页最多返回多少条poiitemquery.setPageNum(currentPage);// 设置查第一页if (lp != null) {poiSearch = new PoiSearch(this, query);poiSearch.setOnPoiSearchListener(this);poiSearch.setBound(new SearchBound(lp, 2500, true));//// 设置搜索区域为以lp点为圆心,其周围2500米范围poiSearch.searchPOIAsyn();// 异步搜索}}
3:对搜索的结果添加marker的操作;
@Overridepublic void onPoiSearched(PoiResult result, int rcode) {if (rcode == 1000) {if (result != null && result.getQuery() != null) {// 搜索poi的结果if (result.getQuery().equals(query)) {// 是否是同一条poiResult = result;poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始List<SuggestionCity> suggestionCities = poiResult.getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息if (poiItems != null && poiItems.size() > 0) {if (poiItems != null && poiItems.size() > 0) {
myPoiOverlay poiOverlay = new myPoiOverlay(aMap, poiItems);poiOverlay.removeFromMap();poiOverlay.addToMap();// poiOverlay.zoomToSpan();} else if (suggestionCities != null && suggestionCities.size() > 0) {showSuggestCity(suggestionCities);} else {//ToastUtil.ShowCentre(MainActivity.this, "对不起,没有搜索到相关数据");}}}}}}
4:把布局文件作为marker的样式;
protected BitmapDescriptor getBitmapDescriptor(int arg0) {if (arg0 < 10) {View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.marker_item, null);return BitmapDescriptorFactory.fromView(view);} else {View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.marker_no, null);return BitmapDescriptorFactory.fromView(view);}}
5:对地图移动的检测;
aMap.setOnCameraChangeListener(this);
@Overridepublic void onCameraChange(CameraPosition position) {LatLng target = position.target;// Log.e("pony_log", target.latitude + "jinjin------" +// target.longitude);}@Overridepublic void onCameraChangeFinish(CameraPosition position) {// TODO Auto-generated method stubLatLng target = position.target;doSearchQuery(new LatLonPoint(target.longitude, target.latitude));Log.e("pony_log", target.latitude + "jinjin------" + target.longitude);}
至此,这块的逻辑功能就完成了;
效果就是:
源码在此,供大家交流:
源码地址
0 0
- Pony,仿支付宝到位动态加载marker效果
- 众觅,让支付宝『到位』全国到位
- 众觅,让支付宝『到位』全国到位
- Android数字动态显示,仿支付宝app效果简单的实现。字数从0-x!!!
- Android简单实现仿支付宝新年红包活动页面的动态布局效果
- Android数字动态显示,仿支付宝app效果简单的实现。字数从0-x!!!
- 仿支付宝注册页面效果
- Android仿支付宝九宫图效果
- 封装仿支付宝密码输入效果
- 仿支付宝咻一咻效果
- UITableView动态加载cell,仿百度贴吧效果
- iOS-仿支付宝刮刮乐效果
- androidの高仿支付宝扫描动画效果
- Android 仿支付宝9.0芝麻信用分效果
- iOS核心动画实现仿支付宝咻咻、雷达效果
- RecycleView 仿支付宝实现item拖动效果
- 简单仿支付宝/微信密码输入效果
- 仿支付宝账单的效果(listview分组 )
- VoltDB 实战
- csv_test.csv
- xml&Tomcat&Servlet笔记
- 史上最完整的Android开发工具集合(转)
- Centos6.5下Qt5.7开发遇到的一些问题
- Pony,仿支付宝到位动态加载marker效果
- ECharts · Doc
- c++中使用Tesseract-OCR
- 使用ant脚本编译web工程并自动部署到tomcat
- RTMPDump源码分析-main函数(1)
- Genymotion模拟器无法开启的解决方法——Unable to start the virtual device,The virtual device got no IP address
- 数据结构与算法1
- STM32’s I2C 硬件BUG引发的血案
- StringUtils.equals() 用法