OSM-使用自定义图标显示当前位置 [英] OSM - Show current location with custom icon

查看:182
本文介绍了OSM-使用自定义图标显示当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何使用自定义图标在OSM地图上显示我的当前位置?

Can anyone tell me how can I show my current location on OSM map with custom icon?

推荐答案

带有默认人物图标::

With default person icon ::

MyLocationNewOverlay myLocationoverlay = new MyLocationNewOverlay(mapView);
myLocationoverlay.enableFollowLocation();
myLocationoverlay.enableMyLocation();
mapView.getOverlays().add(myLocationoverlay);

带有自定义图标::

MyLocationNewOverlay myLocationoverlay = new MyLocationNewOverlay(mapView);
myLocationoverlay.enableFollowLocation();
 Drawable currentDraw = ResourcesCompat.getDrawable(getResources(), R.mipmap.ic_launcher, null);
            Bitmap currentIcon = null;
            if (currentDraw != null) {
                currentIcon = ((BitmapDrawable) currentDraw).getBitmap();
            }
myLocationoverlay.enableMyLocation();
mapView.getOverlays().add(myLocationoverlay);

我正在使用更新的OSM依赖项

I am using updated OSM dependency

compile 'org.osmdroid:osmdroid-android:5.6.5'

这篇关于OSM-使用自定义图标显示当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆