使用OSMbonuspack_v5.1创建上下文菜单

时间:2015-11-13 06:15:49

标签: android overlay android-mapview openstreetmap osmdroid

我正在使用osmbonuspack_v5.1来处理我的OpenStreet mapview和地图上的长按事件。现在我需要在有长按事件时启动上下文菜单。由于添加了registerForContextMenu (View view),地图视图无法获取事件,因此overlays无效。我想知道在osmbonuspack中是否已经有一些实现来调出上下文菜单。

我的代码到目前为止。

@Override
public boolean longPressHelper(GeoPoint geoPoint) {
    // show the menu here to send event
    latitude = Double.toString(geoPoint.getLatitude());
    longitude = Double.toString(geoPoint.getLongitude());

//        ServiceAdapter.publishGlobal(TOPIC_NAME, EVENT_NAME, latitude + longitude);
    Intent listViewIntent = new Intent(this, ListViewActivity.class);
    startActivity(listViewIntent);
    mapView.invalidate();
//        Toast.makeText(this, "Event at (" + latitude + " , " + longitude + ")", Toast.LENGTH_SHORT).show();
    return true;
}

正如您所看到的,我在长按时手动尝试调出列表视图活动。如果没有默认实现可能是我将要做的事情。

1 个答案:

答案 0 :(得分:1)

"我想知道osmbonuspack中是否已经有一些实现来调出上下文菜单。"

=>是的,在OSMNavigator MapActivity

有2个技巧(挂钩菜单,按下geoPoint),查看源代码中的注释。

相关问题