Google Maps Android API v2: My location marker always over other markers?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 07:55:32

After a bit a searching, I couldn't find such an option.

I finally removed the location pin, and added a similar Marker and Circle to the map; since it is a classic Marker, it appears below the other markers.

map.setMyLocationEnabled(false);

// ...
// get the current location with Android LocationManager in some way
// ...

// then draw it on the map when it changes:
if (null == getMyLocation())
    return;

if (null != locationMarker) {
    locationMarker.remove();
}
if (null != locationCircle) {
    locationCircle.remove();
}
LatLng loc = getMyLocation();

locationMarker = map.addMarker(new MarkerOptions()
        .icon(BitmapDescriptorFactory
                .fromResource(R.drawable.blue_pin_12))
        .position(getMyLocation()).anchor(0.5f, 0.5f));

float accuracy = getMyLocationAccuracy();

locationCircle = map.addCircle(new CircleOptions().center(loc)
            .radius(accuracy)
            .strokeColor(Color.argb(255, 0, 153, 255))
            .fillColor(Color.argb(30, 0, 153, 255)).strokeWidth(2));

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!