66import androidx .annotation .NonNull ;
77import androidx .appcompat .app .AppCompatActivity ;
88
9+ import com .kathmandulivinglabs .navigationlibrary .models .Geocode ;
910import com .kathmandulivinglabs .navigationlibrary .models .Geometry ;
11+ import com .kathmandulivinglabs .navigationlibrary .models .Place ;
1012import com .kathmandulivinglabs .navigationlibrary .services .Baato ;
13+ import com .kathmandulivinglabs .navigationlibrary .services .BaatoReverseGeoCodeService ;
1114import com .kathmandulivinglabs .navigationlibrary .services .ToasterMessage ;
1215import com .kathmandulivinglabs .navigationlibrary .utilities .BaatoUtil ;
1316import com .mapbox .api .directions .v5 .models .DirectionsResponse ;
3134import retrofit2 .Response ;
3235
3336public class MainActivity extends AppCompatActivity implements OnMapReadyCallback ,
34- MapboxMap .OnMapLongClickListener , Callback < DirectionsResponse > {
37+ MapboxMap .OnMapLongClickListener {
3538
3639 private static final String TAG = "apple" ;
3740 private MapboxMap mapboxMap ;
@@ -49,15 +52,31 @@ protected void onCreate(Bundle savedInstanceState) {
4952 mapView .getMapAsync (this );
5053 ToasterMessage .s (this , "Hello Good Morning" );
5154 Geometry geometry = BaatoUtil .getGeoJsonFromEncodedPolyLine (encoded );
52- Log .d (TAG , "onCreate: " + Baato .search (Constants .TOKEN , "chardhunga" ).toString ());
53- NavigationRoute .builder (this )
54- .accessToken (Mapbox .getAccessToken ())
55- .origin (Point .fromLngLat (85.4278774 , 27.6721352 ))
56- .destination (Point .fromLngLat (85.3346386 , 27.7340328 ))
57- .alternatives (true )
58- .build ()
59- .getRoute (this );
60- Log .d ("hello" , "onCreate: " + geometry .coordinates );
55+ new BaatoReverseGeoCodeService (this )
56+ .setGeoCode (new Geocode (27.73405 , 85.33685 ))
57+ .setAccessToken (Constants .TOKEN )
58+ .setRadius (2 )
59+ .withListener (new BaatoReverseGeoCodeService .BaatoReverseGeoCodeRequestListener () {
60+ @ Override
61+ public void onSuccess (List <Place > places ) {
62+ Log .d (TAG , "onSuccess:reverse " + places .toString ());
63+ }
64+
65+ @ Override
66+ public void onFailed (Throwable error ) {
67+ Log .d (TAG , "onFailed:reverse " + error .getMessage ());
68+ }
69+ })
70+ .doReverseGeoCode ();
71+ // Log.d(TAG, "onCreate: " + Baato.search(Constants.TOKEN, "chardhunga").toString());
72+ // NavigationRoute.builder(this)
73+ // .accessToken(Mapbox.getAccessToken())
74+ // .origin(Point.fromLngLat(85.4278774, 27.6721352))
75+ // .destination(Point.fromLngLat(85.3346386, 27.7340328))
76+ // .alternatives(true)
77+ // .build()
78+ // .getRoute(this);
79+ // Log.d("hello", "onCreate: " + geometry.coordinates);
6180 }
6281
6382 @ Override
@@ -69,38 +88,13 @@ public boolean onMapLongClick(@NonNull LatLng point) {
6988 public void onMapReady (@ NonNull MapboxMap mapboxMap ) {
7089 this .mapboxMap = mapboxMap ;
7190 mapboxMap .setStyle (Style .MAPBOX_STREETS , style -> {
72- initializeLocationComponent (mapboxMap );
91+ // initializeLocationComponent(mapboxMap);
7392// navigationMapRoute = new NavigationMapRoute(null, mapView, mapboxMap);
7493 mapboxMap .addOnMapLongClickListener (this );
7594// Snackbar.make(mapView, "Long press to select route", Snackbar.LENGTH_SHORT).show();
7695 });
7796 }
7897
79- @ SuppressWarnings ("MissingPermission" )
80- private void initializeLocationComponent (MapboxMap mapboxMap ) {
81- LocationComponent locationComponent = mapboxMap .getLocationComponent ();
82- locationComponent .activateLocationComponent (this , mapboxMap .getStyle ());
83- locationComponent .setLocationComponentEnabled (true );
84- locationComponent .setRenderMode (RenderMode .COMPASS );
85- locationComponent .setCameraMode (CameraMode .TRACKING );
86- locationComponent .zoomWhileTracking (10d );
87- }
88-
89- @ Override
90- public void onResponse (Call <DirectionsResponse > call , Response <DirectionsResponse > response ) {
91- if (response .isSuccessful ()
92- && response .body () != null
93- && !response .body ().routes ().isEmpty ()) {
94- List <DirectionsRoute > routes = response .body ().routes ();
95- // navigationMapRoute.addRoutes(routes);
96- }
97- }
98-
99- @ Override
100- public void onFailure (Call <DirectionsResponse > call , Throwable t ) {
101- Log .d (TAG , "onFailure: " + t .getMessage ());
102- }
103-
10498 @ Override
10599 public void onResume () {
106100 super .onResume ();
0 commit comments