我想从标记中获取数据并传递给onInfoWindowClick()
。我在marker.setTag(endx);
中为标记设置了标记。但它会给出错误NumberFormatException
。有什么方法可以解决这个问题吗?
这是我的代码:
while (cursor.moveToNext()){
title = cursor.getString(1).toString();
__global_endposition = cursor.getString(2).toString();
String[] exp_endCoordinate = __global_endposition.split(",");
lat_endposition = Double.parseDouble(exp_endCoordinate[0]);
lng_endposition = Double.parseDouble(exp_endCoordinate[1]);
LatLng endx = new LatLng(lat_endposition, lng_endposition);
MarkerOptions options = new MarkerOptions();
options.position(endx);
options.title(title);
options.snippet(__global_endposition);
if (title.equals("ATM BNI")){
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE));
}else if(title.equals("ATM BCA")){
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
}else if(title.equals("ATM Mandiri")){
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
}
Marker marker = mMap.addMarker(options);
marker.setTag(endx);
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(getActivity()));
mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
// I want to get current location LatLong and selected location LatLong
// I want execute the LatLong on this method
// this just for testing
String mLatLong = String.valueOf(marker.getTag()).toString();
String[] exp_endKoordinat = mLatLong.split(",");
double mLat = Double.parseDouble(exp_endKoordinat[0]);
double mLng = Double.parseDouble(exp_endKoordinat[1]);
// Toast.makeText(getActivity(), "LatLng: "+mLatitude+", "+mLongitude, Toast.LENGTH_SHORT).show();
Log.d(TAG, "onInfoWindowClick: LatLong Destonation : "+mLat+", "+mLng);
}
});
}
这是错误: