<\/HEAD>
以下のコードはスクリーンポイントで動作し、そこから詳細を取得します:- <\/P>
\/\**
<\/SPAN> * 指定されたscreenpointでレイヤーの識別を行い、handleIdentifyResults(...)を呼び出して処理します。
<\/SPAN> *\/<\/SPAN>
private void <\/SPAN>identifyResult(android.graphics.Point screenPoint) {
final <\/SPAN>ListenableFuture<List<IdentifyLayerResult>> identifyLayerResultsFuture = map
.identifyLayersAsync(screenPoint, 12<\/SPAN>, false<\/SPAN>, 10<\/SPAN>);
identifyLayerResultsFuture.addDoneListener(() -> {
try <\/SPAN>{
List<IdentifyLayerResult> identifyLayerResults = identifyLayerResultsFuture.get();
handleIdentifyResults(identifyLayerResults);
} catch <\/SPAN>(InterruptedException | ExecutionException e) {
Log.e("main"<\/SPAN>, "結果の識別中にエラーが発生しました: " <\/SPAN>+ e.getMessage());
} catch <\/SPAN>(Exception e) {
e.printStackTrace();
}
});
}
\/\**
<\/SPAN> * 識別結果を文字列に処理し、それをshowAlertDialog(...)に渡します。
<\/SPAN> *
<\/SPAN> * <\/SPAN>@param <\/SPAN>identifyLayerResultsはidentifyResult()で生成された識別結果のリストです。
<\/SPAN> *\/<\/SPAN>
private void <\/SPAN>handleIdentifyResults(List<IdentifyLayerResult> identifyLayerResults) {
for <\/SPAN>(IdentifyLayerResult identifyLayerResult : identifyLayerResults) {
geoElementsCountFromResult(identifyLayerResult);
}
}
\/\**
<\/SPAN> * 渡された結果レイヤー内のGeoElementsの数を取得します。
<\/SPAN> *
<\/SPAN> * <\/SPAN>@param <\/SPAN>単一レイヤーからの結果。
<\/SPAN> * <\/SPAN>@return <\/SPAN>GeoElementsの合計数。
<\/SPAN> *\/<\/SPAN>
private void <\/SPAN>geoElementsCountFromResult(IdentifyLayerResult result) {
List<IdentifyLayerResult> tempResults = new <\/SPAN>ArrayList<>();
tempResults.add(result);
int <\/SPAN>index = 0<\/SPAN>;
IdentifyLayerResult identifyResult = tempResults.get(index);
if <\/SPAN>(identifyResult.getSublayerResults().size() > 0<\/SPAN>) {
String siteName = Objects.requireNonNull(identifyResult.getSublayerResults().get(index).getElements().get(index).getAttributes().get("SiteName"<\/SPAN>)).toString();
String siteCode = Objects.requireNonNull(identifyResult.getSublayerResults().get(index).getElements().get(index).getAttributes().get("SiteCode"<\/SPAN>)).toString();
getMarkerPopUp(siteName, siteCode);
}
}
マップのサブレイヤーからすべてのデータを取得しようとすると、jsonEbeddedExcpetionが発生します。
<\/PRE><\/BODY><\/HTML>