osmdroid 显现自己的位置图标是通过GPS,虽然提供了接口替换为其他,但是不知道为什么我没有试成功。

下面通过另一种方式实现   通过百度定位显示个人图标。

原始实现 默认的个人定位图标。

//            if (mLocationOverlay==null){//                mLocationOverlay= new MyLocationNewOverlay(mMapView);//                Bitmap bitmap = MyUtils.zoomImg(BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.renyuan), 80, 80);////                mLocationOverlay.setDirectionArrow(bitmap,//                        ((BitmapDrawable)//                                mMapView.getContext().getResources().getDrawable(org.osmdroid.library.R.drawable.person)).getBitmap());//            }//            mMapView.getOverlays().add(mLocationOverlay);//            mLocationOverlay.enableMyLocation();  //设置可视

 

通过 自己实现 IMyLocationProvider这个接口理论可以实现 定位,但是我个人尝试的时候并没有实现。

不过好在

Marker可以不断设计位置。所有可以不断维护一个Marker,不断设置位置就可以了。所以
/** *     设置个人新的位置 * @return */public void setMyLocationInfo(GeoPoint latLng){    if (latLng == null) return;    initLocationMarker();    mLocationMarker.setPosition(latLng);    setPositionCenter(latLng);}

 

private void initLocationMarker() {    if (mLocationMarker!=null){        return;    }    mLocationMarker = new Marker(mMapView);    mLocationMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);    mLocationMarker.setInfoWindow(null);    Bitmap bitmap = MyUtils.zoomImg(BitmapFactory.decodeResource(mContext.getResources(),R.mipmap.renyuan), 300, 300);    BitmapDrawable bd= new BitmapDrawable(bitmap);    mLocationMarker.setIcon(bd);    mMapView.getOverlays().add(mLocationMarker);}

 

/** * 设置中心点 */public void setPositionCenter(GeoPoint latLng) {    mMapView.getController().setCenter(latLng);}

 

 

更多相关文章

  1. Android(安卓)5.0学习之定义阴影
  2. Activity伪造Dialog的时候不能全屏显示
  3. Android中TextView文字设置不同的颜色
  4. 【Android】强大的SpannableStringBuilder
  5. 在Eclipse中设置Android模拟器屏幕大小
  6. android中setOnClickListener的那点事
  7. Android:窗口的Flag设置作用
  8. android中创建XML
  9. [Android(安卓)UI界面] ListView与arrays.xml结合使用的问题

随机推荐

  1. 当开始使用数据-*时,无法识别AngularJS指
  2. 如何禁用Cell Handsontable中的写入并包
  3. ajax交互Struts2的action(1)
  4. 如何设置动画以使元素围绕圆圈移动?
  5. 通过切换a. localecompare (b) to (ab?1:
  6. 在Angular服务中使用$ http作为json数据
  7. JSON.parse(xhr.responseText)意外的字符串
  8. [jQuery知识]jQuery之知识四-DOM和CSS操
  9. 与jQuery ajax post方法相比,fetch方法没
  10. JavaScript中可见性检查的测试条件