I have a class named MapViewManager, in it I have a method called navigate like below:
public class MapViewManager{
...
public void navigate(double startX, double startY, double toX, double toY, long floorId, boolean flag) {
final FeatureLayer featureLayer = new FeatureLayer("navigate");
mapView.setLayerOffset(featureLayer);
mapView.addLayer(featureLayer);
final NavigateManager navigateManager = new NavigateManager();
if (flag) {
navigateManager.navigation(startX, startY, floorId, toX, toY, floorId);
}else{
navigateManager.clear();
}
navigateManager.setOnNavigateComplete(new NavigateManager.OnNavigateComplete() {
@Override
public void onNavigateComplete(NavigateManager.NavigateState navigateState,
FeatureCollection featureCollection) {
featureLayer.clearFeatures();
featureLayer.addFeatures(featureCollection);
for (int i=0;i<featureCollection.getSize();i++){
Feature feature = featureCollection.getFeature(i);
Coordinate coordinate = feature.getCentroid();
double x = coordinate.getX();
double y = coordinate.getY();
}
}
});
}
}
I want to access the variable named coordinate in onNavigateComplete callback method from outside so that other classes can use the coordinate variable to do something. How can I make it?
Add one more parameter to navigate method.
Call method from other Class :
Now you can access any object anywhere.