如何将我的 Android 应用程序 Google 地图半径圆替换为蓝色半透明圆,如图所示,还有带有蓝色圆的蓝色标记?
我可以使圆圈具有特定的轮廓并填充,但它看起来并不像下图所示的那么好。我怎么做?到目前为止我的代码也在下面。
Code:
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
LatLng latLng = new LatLng(28.982518, -81.542272);
gooleMap.addMarker(new MarkerOptions().position(latLng));
Circle circle = gooleMap.addCircle(new CircleOptions()
.center(new LatLng(28.982518, -81.542272))
.radius(1000)
.strokeColor(Color.RED)
.fillColor(Color.PURPLE));
mMap.addCircle(new CircleOptions()
.center(center)
.radius(radius)
.strokeWidth(0f)
.fillColor(0x550000FF));
}
}
@Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
安卓 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Image:
为了确认,我想做的是:
显示上面的效果,一个深蓝色的圆圈,里面有半透明的浅蓝色填充,如上图所示
CircleOptions circleOptions = new CircleOptions()
.center(latlng)
.radius(500)
.strokeWidth(2)
.strokeColor(Color.BLUE)
.fillColor(Color.parseColor("#500084d3"));
// Supported formats are: #RRGGBB #AARRGGBB
// #AA is the alpha, or amount of transparency
mMap.addCircle(circleOptions);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)