我有以下代码,我想在其中显示标记,位置的纬度和经度存储在数组中,但我的标记没有显示在 map 上,我不知道为什么:|我打印了这些值以检查值是否正确但未显示标记
if (f[l].equals(restTypefrag[n])) {
Log.i("okkk", "lattitude " + la[n] + "longtitude " + lo[n] +"name " + namefrag[n]);
**Marker marker= mMap.addMarker(new MarkerOptions().position(new
LatLng(la[n], lo[n])).title("" + namefrag[n]));**
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
// Log.i("okkk", " On marker Click ");
AlertDialog.Builder alertadd = new AlertDialog.Builder(getActivity());
LayoutInflater factory = LayoutInflater.from(getActivity());
final View view = factory.inflate(R.layout.alert, null);
TextView alertName=(TextView) view.findViewById(R.id.tv_name);
TextView alertDeal=(TextView) view.findViewById(R.id.tv_deal);
String temp=marker.getTitle();
for (int i=0;i<namefrag.length;i++)
{
// Log.i("okkk", " Name: " + temp);
if (temp.equals(namefrag[i]))
{
tempName=namefrag[i];
tempDeal=dealfrag[i];
Log.i("okkk", " Name: " + namefrag[i]);
}
}
RatingBar alertRating=(RatingBar) view.findViewById(R.id.rb_alert);
alertRating.setNumStars(5);
alertRating.setRating(3.5f);
alertName.setText(tempName);
alertDeal.setText(tempDeal);
alertadd.setView(view);
alertadd.show();
return false;
}
});
Notifications(namefrag[l], distance[Index]);
最佳答案
像这样使用...
Marker marker= mMap.addMarker(new MarkerOptions().position(new LatLng(la[n], lo[n])).title("" + namefrag[n])).icon(BitmapDescriptorFactory.fromResource(R.drawable.driver_img));
关于java - 标记未显示在谷歌地图上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42529747/