Java android打开街道地图CustomInfoWindow关闭infoWindow单击图像时

时间:2017-03-17 10:33:11

标签: java android openstreetmap osmdroid

这就是我创建CustomInfoWindow的方式:

private class CustomInfoWindow extends MarkerInfoWindow {
POI mSelectedPoi;

CustomInfoWindow(MapView mapView) {
    super(R.layout.bonuspack_bubble, mapView);
    Button btn = (Button) (mView.findViewById(R.id.bubble_moreinfo));
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Singleton si = Singleton.getInstance();
            ObjectDefExtends obj = si.getCurrentObject();
            if (obj != null && Singleton.getInstance().getListaVisible().size() > 0) {
                ObjectDefExtends currentObject = si.getCurrentObject();
                double latitude = currentObject.lat;
                double longitude = currentObject.lon;
                String label = currentObject.name;
                String uriBegin = "geo:" + latitude + "," + longitude;
                String query = latitude + "," + longitude + "(" + label + ")";
                String encodedQuery = Uri.encode(query);
                String uriString = uriBegin + "?q=" + encodedQuery + "&z=16";
                Uri uri = Uri.parse(uriString);
                Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
                startActivity(intent);
            }
        }
    });
}

@Override
public void onOpen(Object item) {
    super.onOpen(item);
    mView.findViewById(R.id.bubble_moreinfo).setVisibility(View.VISIBLE);
    Marker marker = (Marker) item;
    mSelectedPoi = (POI) marker.getRelatedObject();
}
}

当我点击btn并转到新意图时,我尝试这样做我想要关闭这个InfoWindow。当我一直看到这个InfoWindow

时,我会从这个意图中回过头来

1 个答案:

答案 0 :(得分:0)

finish();

之后致电startActivity(intent);