问题
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