目前正在将使用Google地图的Android应用程序迁移至Google Maps Android v2。 我希望地图能显示内置位置标记以及自定义标记。 在使用先前的库时,我会将位置标记绘制在自定义标记“下方”,具体方法为:
mapView.setReticleDrawMode(ReticleDrawMode.DRAW_RETICLE_UNDER);
我在新API中找不到类似的选项,是我漏掉了什么吗?
目前正在将使用Google地图的Android应用程序迁移至Google Maps Android v2。 我希望地图能显示内置位置标记以及自定义标记。 在使用先前的库时,我会将位置标记绘制在自定义标记“下方”,具体方法为:
mapView.setReticleDrawMode(ReticleDrawMode.DRAW_RETICLE_UNDER);
我在新API中找不到类似的选项,是我漏掉了什么吗?
经过一番搜索,我没有找到这样的选项。
最终我移除了位置图钉,并在地图上添加了一个类似的标记和圆圈;由于它是一个传统的标记,它出现在其他标记下面。
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));