Select to view content in your preferred language

How to zoom to a query result

2997
1
02-20-2016 02:19 PM
FatmaŞenol
Frequent Contributor

Hello,

I'm working on developing an application using ArcGIS Runtime SDK for Android.

I created number of web maps in ArcGIS Online  and the application uses these

web maps as source layers.

When I make a query in map viewer  in ArcGIS Online, the zoom level is changed and  the selected feature(s)

are centered. However, when I try the same thing in my application, the result is not the same.

The following piece of code is written to perform such operation but apparently I missed

something. 

--------------------------------------------------------------------------------------------------------

mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {

            private static final long serialVersionUID = 1L;

            public void onStatusChanged(Object source, STATUS status) {

                if (source == URL && status == STATUS.LAYER_LOADED) {

                    mMapView.centerAt(1.286389, 103.79, false);

                    mMapView.setScale(1500, false);

                }

            }

-------------------------------------------------------------------------------------------------------

It would be great if you could help me on this issue.  Thank you in advance.

0 Kudos
1 Reply
WillCrick
Deactivated User

I think you might have a few steps missing. First, depending on your layer type, you need to query for the feature (QueryTask is probably the best place to start if its a feature layer or map service layer in your webmap). If this is a predefined query configured in your webmap, you might also need to get parameters from the predefined queries parameter.

Once you have executed a query, you can then use the methods you used above on the mapview (centre at, set scale) to zoom to the features geometry in the query result/s. You may also want to select the feature (if using a feature layer) through the selectGraphics method.

The following samples may help you:

arcgis-runtime-samples-android/QueryCloudFeatureService at master · Esri/arcgis-runtime-samples-andr...

arcgis-runtime-samples-android/QueryTask at master · Esri/arcgis-runtime-samples-android · GitHub

0 Kudos