【发布时间】:2020-05-06 21:59:25
【问题描述】:
我在这里https://docs.mapbox.com/android/maps/examples/support-map-fragment/ 遵循了 Mapbox 的说明,我可以成功地从 MapFragment 可视化地图。
//Create the mapFragment
if (savedInstanceState == null) {
// Create fragment
final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// Build mapboxMap
MapboxMapOptions options = MapboxMapOptions.createFromAttributes(this, null).doubleTapGesturesEnabled(true);
options.camera(new CameraPosition.Builder()
.target(new LatLng(-52.6885, -70.1395))
.zoom(14)
.build());
// Create map fragment
mapFragment = SupportMapFragment.newInstance(options);
// Add map fragment to parent container
transaction.add(R.id.container, mapFragment, "com.mapbox.map");
transaction.commit();
} else {
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag("com.mapbox.map");
// Working with Fragment - getFragment by ID
}
if (mapFragment != null) {
mapFragment.getMapAsync(this);
}
现在我想介绍 LineManager,以便在注释插件的帮助下定义一些行,在这里找到https://docs.mapbox.com/android/plugins/overview/annotation/ 但问题是,我无法初始化它,因为这部分:
LineManager lineManager = new LineManager(mapView, mapboxMap, style);
我有 mapboxMap 和样式,但我没有 mapView。
那么我们如何从 Mapbox 定义的 MapFragment 中获取 mapView 呢?
【问题讨论】:
标签: java android mapbox mapbox-android