ViewPager中的页面使用MAP滚动

时间:2018-09-14 08:48:39

标签: android-scrollview mapbox-android

我有一个页面,其中包含MAPBOX中的地图(不是Google Maps),所以一切正常,除非我滚动地图,页面也会滚动,所以有什么方法可以阻止页面滚动(我已经测试过Google Maps ,我没有发现这个问题)。

这是我的代码

{


            airMapView =   v.findViewById(R.id.map);

            airMapView.onCreate(savedInstanceState);

            airMapView.getMapAsync(new com.mapbox.mapboxsdk.maps.OnMapReadyCallback() {
                @Override
                public void onMapReady(MapboxMap mapboxMap) {

                    Coordinates myLocation = null;
                    mapboxMap.setStyle(Style.MAPBOX_STREETS);
                    if(infraction != null && infraction.getLocation() != null)
                    {
                        myLocation = infraction.getLocation().getCoordinates();

                    }
                    else if(newInfraction != null && newInfraction.getLocation() != null)
                    {
                        myLocation = newInfraction.getLocation().getCoordinates();

                    }

                    double latitude = myLocation.getLatitude();
                    double longitude = myLocation.getLongitude();

                    com.mapbox.mapboxsdk.camera.CameraPosition cameraPosition =
                            new   com.mapbox.mapboxsdk.camera.CameraPosition.Builder()
                            .target(new com.mapbox.mapboxsdk.geometry.LatLng(latitude,longitude))
                            .zoom(11)
                            .tilt(30)
                            .build();
                   mapboxMap.setCameraPosition(cameraPosition);

                    com.mapbox.mapboxsdk.annotations.Marker marker = mapboxMap.addMarker(new com.mapbox.mapboxsdk.annotations.MarkerOptions().setPosition(new com.mapbox.mapboxsdk.geometry.LatLng(latitude,longitude))
                            .setTitle(infraction.getTitle_infraction()));
                    mapboxMap.getUiSettings().setDeselectMarkersOnTap(false);
                    mapboxMap.selectMarker(marker);

                   }
            });

        }

这是我的布局:

       <com.mapbox.mapboxsdk.maps.MapView
    android:id="@+id/map"
    android:layout_marginTop="6dp"
    android:layout_marginRight="4dp"
    android:layout_marginLeft="4dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/Scroll_infraction_details"/>

enter image description here

0 个答案:

没有答案