How to get data from all sublayers from ServiceFeatureTable? I am able to fetch layer details on basis of touch point.

162
0
01-02-2020 04:45 AM
Puneetkumar
New Contributor

Below code is working for screenpoint and get details from it:- 

/**
 * Performs an identify on layers at the given screenpoint and calls handleIdentifyResults(...) to process them.
 */
private void identifyResult(android.graphics.Point screenPoint) {
    final ListenableFuture<List<IdentifyLayerResult>> identifyLayerResultsFuture = map
            .identifyLayersAsync(screenPoint, 12, false, 10);
    identifyLayerResultsFuture.addDoneListener(() -> {
        try {
            List<IdentifyLayerResult> identifyLayerResults = identifyLayerResultsFuture.get();
            handleIdentifyResults(identifyLayerResults);
        } catch (InterruptedException | ExecutionException e) {
            Log.e("main", "Error identifying results: " + e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
}

/**
 * Processes identify results into a string which is passed to showAlertDialog(...)
 *
 * @param identifyLayerResults a list of identify results generated in identifyResult().
 */
private void handleIdentifyResults(List<IdentifyLayerResult> identifyLayerResults) {
    for (IdentifyLayerResult identifyLayerResult : identifyLayerResults) {
        geoElementsCountFromResult(identifyLayerResult);
    }
}

/**
 * Gets a count of the GeoElements in the passed result layer
 *
 * @param result from a single layer.
 * @return the total count of GeoElements.
 */
private void geoElementsCountFromResult(IdentifyLayerResult result) {
    List<IdentifyLayerResult> tempResults = new ArrayList<>();
    tempResults.add(result);
    int index = 0;
    IdentifyLayerResult identifyResult = tempResults.get(index);
    if (identifyResult.getSublayerResults().size() > 0) {
        String siteName = Objects.requireNonNull(identifyResult.getSublayerResults().get(index).getElements().get(index).getAttributes().get("SiteName")).toString();
        String siteCode = Objects.requireNonNull(identifyResult.getSublayerResults().get(index).getElements().get(index).getAttributes().get("SiteCode")).toString();
        getMarkerPopUp(siteName, siteCode);
    }
}

In case of getting all data from sublayers of map, i am getting jsonEbeddedExcpetion.

0 Kudos
0 Replies