[英]Markers not shown at google map
I have following code in which I want to show marker, the latitude and longitude of place is stored in array but I my markers are not showing on map I don't know why :| 我有以下代码,我想显示标记,地方的纬度和经度存储在数组中,但我的标记没有显示在地图上我不知道为什么:| I printed these values for checking values are correct but marrker not shown 我打印这些值是为了检查值是否正确但是没有显示marrker
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]);
in your onMarkerClick()
return true. 在你的onMarkerClick()
返回true。
@Override
public boolean onMarkerClick(Marker marker) {
marker.showInfoWindow();
return true;
}
像这样使用......
Marker marker= mMap.addMarker(new MarkerOptions().position(new LatLng(la[n], lo[n])).title("" + namefrag[n])).icon(BitmapDescriptorFactory.fromResource(R.drawable.driver_img));
Have you set up the icon for your marker ? 您是否为标记设置了图标?
map.addMarker(new MarkerOptions()
.position(new LatLng(myLat, myLong))
.title("Bla Bla").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
I think it is not set up in your code. 我认为它没有在你的代码中设置。 Kindly try to set up icon to marker. 请尝试将图标设置为标记。
Are you sure that your variables la[n]
and lo[n]
are double ? 你确定你的变量la[n]
和lo[n]
是双倍的吗?
If they are String, you can use Double.parseDouble(String)
to convert them to double : 如果它们是String,您可以使用Double.parseDouble(String)
将它们转换为double:
double lat = Double.parseDouble(la[n]);
double lon = Double.parseDouble(lo[n]);
Marker marker = mMap.addMarker(new MarkerOptions().position(new
LatLng(lat, lon)).title("" + namefrag[n]));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.