Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 地图框:路线下方显示位置符号(圆盘)_Java_Android_Mapbox - Fatal编程技术网

Java 地图框:路线下方显示位置符号(圆盘)

Java 地图框:路线下方显示位置符号(圆盘),java,android,mapbox,Java,Android,Mapbox,有人知道如何使用mapbox Android API将mapbox中的位置“puck”显示在路径上方吗?我遵循了来自的示例,但遗憾的是,它仍然不能像我所希望的那样工作。以下是问题的演示: 以下是初始化映射的方式: mapboxMap.setStyle(style, new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) { loadedStyle

有人知道如何使用mapbox Android API将mapbox中的位置“puck”显示在路径上方吗?我遵循了来自的示例,但遗憾的是,它仍然不能像我所希望的那样工作。以下是问题的演示:

以下是初始化映射的方式:

mapboxMap.setStyle(style, new Style.OnStyleLoaded() {
    @Override
    public void onStyleLoaded(@NonNull Style style) {
        loadedStyle = style;
        initRouteLayer();
        showActiveRoute();
        initIcons();
        initLocationComponent(style);
        initListeners();

        Log.i(TAG, "++ Repaint complete");
    }
});
指定路由的初始化:

private void initRouteLayer() {
    ROUTE_SOURCE_ID = UUID.randomUUID().toString();
    final String routeLayerId = UUID.randomUUID().toString();

    loadedStyle.addSource(new GeoJsonSource(ROUTE_SOURCE_ID,
            FeatureCollection.fromFeatures(new Feature[]{})));

    LineLayer routeLayer = new LineLayer(routeLayerId, ROUTE_SOURCE_ID);

    // Add the LineLayer to the map. This layer will display the directions route.
    routeLayer.setProperties(
            lineCap(Property.LINE_CAP_ROUND),
            lineJoin(Property.LINE_JOIN_ROUND),
            lineWidth(5f),
            lineColor(FrontendUtils.getColor(getContext(), R.color.activeRoute))
    );

    loadedStyle.addLayer(routeLayer);
}

private void showActiveRoute() {
    Log.d(TAG, "Showing active route (activeroute: " + hasActiveRoute()
            + ", fully loaded: " + isFullyLoaded() + ")");

    if(hasActiveRoute() && isFullyLoaded()) {
        // Retrieve and update the source designated for showing the directions route
        GeoJsonSource source = loadedStyle.getSourceAs(ROUTE_SOURCE_ID);

        if(source != null) {
            source.setGeoJson(routes.get(getActiveRouteIndex()));
        }
    }
}
这就是位置组件的初始化方式:

private void initLocationComponent(@NonNull Style loadedMapStyle) {
    // Get an instance of the component
    locationComponent = mapboxMap.getLocationComponent();

    LocationComponentOptions customLocationComponentOptions = LocationComponentOptions.builder(getContext())
            .foregroundDrawable(R.drawable.location_puck)
            .build();

    LocationComponentActivationOptions locationComponentActivationOptions =
            LocationComponentActivationOptions.builder(getContext(), loadedMapStyle)
                    .locationComponentOptions(customLocationComponentOptions)
                    .build();

    // Activate with options
    locationComponent.activateLocationComponent(locationComponentActivationOptions);

    // Enable to make component visible
    locationComponent.setLocationComponentEnabled(true);

    // Set the component's render mode
    locationComponent.setRenderMode(RenderMode.NORMAL);
}
除了由于某种原因在路线下绘制的位置符号外,地图没有其他问题。我将非常感谢你的帮助