Closed ndeso17 closed 2 years ago
This code on MainActivity java
> `private void getRoute(MapboxMap mapboxMap, Point origin, Point destination) { > if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { > return; > } > > client = MapboxDirections.builder() > .origin(origin) > .destination(destination) > .overview(DirectionsCriteria.OVERVIEW_FULL) > .profile(DirectionsCriteria.PROFILE_WALKING) > .accessToken(getString(R.string.mapbox_access_token)) > .build(); > client.enqueueCall(new Callback<DirectionsResponse>() { > @Override > public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) { > Timber.d("Response code: %s", response.code()); > > if (response.body() == null) { > Timber.e("No routes found, make sure you set the right user and access token."); > return; > } else if (response.body().routes().size() < 1) { > Timber.e("No routes found"); > return; > } > > // Get the Direction API response's route > currentRoute = response.body().routes().get(0); > > if (currentRoute != null) { > if (mapboxMap != null) { > mapboxMap.getStyle(new Style.OnStyleLoaded() { > @Override > public void onStyleLoaded(@NonNull Style style) { > > GeoJsonSource originDestinationPointGeoJsonSource = style.getSourceAs(ICON_SOURCE_ID); > > if (originDestinationPointGeoJsonSource != null) { > originDestinationPointGeoJsonSource.setGeoJson(getOriginAndDestinationFeatureCollection()); > } > > GeoJsonSource lineLayerRouteGeoJsonSource = style.getSourceAs(ROUTE_LINE_SOURCE_ID); > > if (lineLayerRouteGeoJsonSource != null) { > > LineString lineString = LineString.fromPolyline(currentRoute.geometry(), PRECISION_6); > lineLayerRouteGeoJsonSource.setGeoJson(Feature.fromGeometry(lineString)); > } > } > }); > } > } else { > Timber.d("Directions route is null"); > Toast.makeText(MainActivity.this, > getString(R.string.route_can_not_be_displayed), Toast.LENGTH_SHORT).show(); > } > } > > @Override > public void onFailure(Call<DirectionsResponse> call, Throwable throwable) { > Toast.makeText(MainActivity.this, > getString(R.string.route_call_failure), Toast.LENGTH_SHORT).show(); > } > }); > }` >
Cannot resolve method 'origin' in 'Builder' the code is now unusable, is there an error in the code? if not, what are the alternatives?
Starting from v6.0.0 you should use RouteOptions to define request parameters. For coordinates you should use RouteOptions.Builder#coordinates(). See docs for more info.
RouteOptions
RouteOptions.Builder#coordinates()
This code on MainActivity java
Cannot resolve method 'origin' in 'Builder' the code is now unusable, is there an error in the code? if not, what are the alternatives?