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

半腔热情 提交于 2019-12-30 02:29:09

问题


Currently migrating an Android app using Google Maps to Google Maps Android v2; I want the map to display the built-in location marker, as well as custom markers. With the previous library, I used to draw the location marker 'below' custom markers, with

mapView.setReticleDrawMode(ReticleDrawMode.DRAW_RETICLE_UNDER);

I can't find a similar option in the new API. Did I miss something?


回答1:


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));



来源:https://stackoverflow.com/questions/13804361/google-maps-android-api-v2-my-location-marker-always-over-other-markers

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