1

最近、ArcGIS for Android の作業を開始しました。私のアプリケーションでは、ArcGIS.com で作成されたサービスを利用でき、Android デバイスでマップを表示できます。特定のレイヤーをクリックしたときに、マップのレイヤー情報を取得したいと考えています。ArcGIS リソースに関する情報はあまりありません。可能であれば、いくつかの例を使用して情報を取得する方法を教えていただければ幸いです。地図を表示するコードは次のとおりです。

プライベート MapView マップ = null;

String dynamicMapURL = " http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer ";

map = (MapView) findViewById(R.id.map);

ArcGISDynamicMapServiceLayer dynamicLayer = new ArcGISDynamicMapServiceLayer(dynamicMapURL); map.addLayer(dynamicLayer);

4

3 に答える 3

0

ArcGIS API が提供するサンプルを使用できます。

ArcGIS のヘルプで、それらの使用方法とそれぞれの機能について説明しています。

リンクは次のとおりです。

サンプル ArcGIS ヘルプ

それが役に立ったことを願っています;)

于 2013-08-20T10:39:53.233 に答える
0

IdentifyTask クラスを試してください。ダイナミック マップ サービスで動作します。

ArcGIS SDK for Android には、Eclipse 用 SDK プラグインの一部として IdentifyTask サンプルがあります。プラグインをインストールしたら、Eclipse で [ファイル] > [新規] > [その他] に移動します。[ArcGIS for Android] > [ArcGIS Samples for Android] を選択します。ローカル サンプルのボックスをオンにして、[タスク] > [IdentifyTask] を選択します。

于 2013-08-27T14:22:53.563 に答える
0

以下は、ArcGIS ランタイム v100.x Android SDK を使用して、ArcGIS マップ フィーチャ レイヤー上のオブジェクトを識別および選択するための簡単なコード スニペットです。

MainActivity.java

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Toast;

import com.esri.arcgisruntime.concurrent.ListenableFuture;
import com.esri.arcgisruntime.data.ArcGISFeature;
import com.esri.arcgisruntime.data.Feature;
import com.esri.arcgisruntime.data.FeatureEditResult;
import com.esri.arcgisruntime.data.FeatureQueryResult;
import com.esri.arcgisruntime.data.QueryParameters;
import com.esri.arcgisruntime.data.ServiceFeatureTable;
import com.esri.arcgisruntime.geometry.Envelope;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.layers.ArcGISTiledLayer;
import com.esri.arcgisruntime.layers.FeatureLayer;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutionException;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    private MapView mMapView = null;
    private ArcGISMap mMap = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mMapView = findViewById(R.id.mapView);
        mMap = new ArcGISMap();
        mMapView.setMap(mMap);

        // Applying base map as tiled layer.
        final Basemap baseMap = new Basemap(new ArcGISTiledLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
        mMap.setBasemap(baseMap);

        final ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable("http://..feature-layer-full-url");
        final FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable);
        featureLayer.setSelectionColor(Color.BLUE);
        featureLayer.setSelectionWidth(10);
        mMap.getOperationalLayers().add(featureLayer);

        final GraphicsOverlay overlay = new GraphicsOverlay();
        mMapView.getGraphicsOverlays().add(overlay);

        mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) {

            @Override
            public boolean onSingleTapConfirmed(MotionEvent event) {

                android.graphics.Point screenPoint = new android.graphics.Point(Math.round(event.getX()), Math.round(event.getY()));
                Point scenePoint = mMapView.screenToLocation(screenPoint);

                int tolerance = 10;
                double mapTolerance = tolerance * mMapView.getUnitsPerDensityIndependentPixel();

                // create objects required to do a selection with a query
                Envelope envelope = new Envelope(scenePoint.getX() - mapTolerance, scenePoint.getY() - mapTolerance, scenePoint.getX() + mapTolerance, scenePoint.getY() + mapTolerance, mMapView.getSpatialReference());
                QueryParameters query = new QueryParameters();
                query.setGeometry(envelope);
                final ListenableFuture<FeatureQueryResult> future = featureLayer.selectFeaturesAsync(query, FeatureLayer.SelectionMode.ADD);

                // add done loading listener to fire when the selection returns
                future.addDoneListener(new Runnable() {
                    @Override
                    public void run() {
                        try {

                            FeatureQueryResult result = future.get();
                            Iterator<Feature> iterator = result.iterator();
                            Feature feature;
                            int counter = 0;
                            while (iterator.hasNext()) {

                                feature = iterator.next();
                                counter++;
                                Log.d(getResources().getString(R.string.app_name), "Selection #: " + counter + " Table name: " + feature.getFeatureTable().getTableName());
                            }

                            Toast.makeText(getApplicationContext(), counter + " features selected", Toast.LENGTH_SHORT).show();

                        } catch (Exception e) {

                            Log.e(getResources().getString(R.string.app_name), "Select feature failed: " + e.getMessage());
                        }
                    }
                });

                return true;
            }
        });

    }

    @Override
    protected void onPause() {
        mMapView.pause();
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.resume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMapView.dispose();
    }

}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical">

    <com.esri.arcgisruntime.mapping.view.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

: これは、Android Studio v3.xx および Java 1.8 で正しく機能しました。

build.gradle (モジュール) :implementation 'com.esri.arcgisruntime:arcgis-android:100.2.1'

build.gradle (プロジェクト) : maven { url ' https://esri.bintray.com/arcgis ' }

于 2018-05-31T07:24:24.027 に答える