gpt4 book ai didi

android - 在android中的 map 中创建标记标题栏的自定义形状

转载 作者:行者123 更新时间:2023-11-29 17:27:48 24 4
gpt4 key购买 nike

我正在使用下面的代码,它给出了一个默认的矩形 shape。我想更改 title barshape,如在图像中

enter image description here

CameraPosition cameraPos = new CameraPosition.Builder()
.target(ll)
.zoom(18).bearing(300).tilt(45).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos), null);

if(racecourseroadmarker!=null)
racecourseroadmarker.remove();
racecourseroadmarker = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(ll.latitude, ll
.longitude)).anchor(0.5f, 0.5f).draggable(true)
.title(getIntent().getStringExtra("busno")).snippet(location)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.bus)));

onMarkerDragStart(racecourseroadmarker);
onMarkerDrag(racecourseroadmarker);
racecourseroadmarker.showInfoWindow();

最佳答案

尝试使用此代码,它将帮助您在谷歌地图标记 fragment 或您可以声明的标题中创建自定义 View

View ll; 
ll = getActivity().getLayoutInflater().inflate(R.layout.markerpopup, null);
tviNamePopup = (TextView) ll.findViewById(R.id.tviNamePopup);

googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker markerss) {
// TODO Auto-generated method stub

String title = markerss.getTitle();
tviNamePopup.setText(title);
return null;
}

@Override
public View getInfoContents(Marker markerss) {
// TODO Auto-generated method stub

// do something here

return ll;
}
});

googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLngs));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(2));

布局是:markerpopup.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/editstyle"
android:orientation="vertical" >

<TextView
android:id="@+id/tviNamePopup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:textColor="#0000FF" />

</LinearLayout>

关于android - 在android中的 map 中创建标记标题栏的自定义形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34060170/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com