QueryTask (or other types of tasks) with ArcGISDynamicMapServiceLayer

2290
6
10-17-2012 03:27 AM
PetarMaletić
New Contributor
If someone can answer the question:

For example, if i am using the ArcGISDynamicMapServiceLayer with dynamic map service resource exposed by the ArcGIS Server for displaying very large number of POIs (points, more than 10000, drawn by ArcGIS server) i know i can use Query, QueryTask, FindTask, IdentifyTask for a variety of user interaction with the map (maptips, identify on click etc.)... but my question is... is there a way of querying ArcGISDynamicMapServiceLayer map service resource (on-the-fly) that would filter (show/hide) out some POIs that are drawn iin that dynamic map service resource? For example, initial map displays 1000 POIs (all POIs), after that user want to see only the selected POIs (from some filter/list) on the map...

Thanks.
0 Kudos
6 Replies
__Rich_
Occasional Contributor III
0 Kudos
PetarMaletić
New Contributor
Thanks, that should be what i was looking for... but... i see SQL syntax is used... and functionality that i have to provide to my users is that they can select (checkbox) or deselect each POI in some list/filter (one or couple of thousands) and when they do... i have toshow only the selected POIs... so sending like 1000+ ID or even more than 10000 (ID = min. 5 digit number plus comma) in WHERE condition... that could be a problem 🙂
0 Kudos
__Rich_
Occasional Contributor III
Thanks, that should be what i was looking for... but... i see SQL syntax is used... and functionality that i have to provide to my users is that they can select (checkbox) or deselect each POI in some list/filter (one or couple of thousands) and when they do... i have toshow only the selected POIs... so sending like 1000+ ID or even more than 10000 (ID = min. 5 digit number plus comma) in WHERE condition... that could be a problem 🙂

Sounds like you need to form the query differently in that case.

e.g. if you want to use the ID field...and it's a sequential number then you might want everything between two limits, rather than listing all the IDs individually...or perhaps a composite of fields will make your where clause shorter.

Or, turn the query upside down and use "not" etc. etc.

I'm sure you'll find a way, just needs some creative problem solving applied 🙂
0 Kudos
__Rich_
Occasional Contributor III
Just an observation - if you're planning on showing your user an explicit list of all the features to allow them to turn things on/off and you're talking about so many features (>10000!) then that's a hell of a lot of data:

a) to send over the wire - I hope all your users have decent connections!
b) to load into the browser - think about the client-side memory impact etc. I hope they all have decent machines!
c) for them to scroll through
d) loads of other considerations 🙂

Perhaps you could provide them with a more generic selection interface or perhaps you could look at techniques such as paging to reduce the load...or perhaps you're comfortable with all this already...
0 Kudos
PaulBushore
Occasional Contributor
Hello,

Mirroring some of the other comments, I think finding some way to compartmentalize the list of POIs is going to be your best bet.  In the root MXD/MSD you could have layers in the map made up of definition queries/query layer/arcsde view that would group certain of the POIs and then they would appear grouped that way in the TOC, allowing people to turn them off or not.  Subsequently, you could have an additional field in the POI feature class that then allows them to be subset even further through an in-application setting of a definition query on the particular layer.  Don't know what it would do to performance, but the marrying of the two methods may work.

Take care,
0 Kudos
DouglasHall
New Contributor III
1. There is query parameter query.objectIds = [12345,23456]; that takes a simple array of objectIds, I assume it is semi-efficient. You could then add as graphics to map. See code below...
2. You may want to check out using a FeatureLayer service using MODE_SELECTION and then selectFeatures(query, selectionMethod?)

var aObjectIds = [];
aObjectIds.push(12345);
aObjectIds.push(67890);

detailQueryTask = new esri.tasks.QueryTask(mapServiceName);
detailQuery = new esri.tasks.Query();
detailQuery.objectIds = aObjectIds;
detailQuery.returnGeometry = true;
detailQuery.outFields = ["*"];
detailQueryTask.execute(detailQuery, function (results) {
    doSomething(results);
    
    if (results.features !== undefined && results.features.length !== 0) {
        zoomToPointFeaturesExtent(results);
        highlightMonuments(results, "STYLE_SQUARE");
}

function zoomToPointFeaturesExtent(results) {
    var xtent,
    xmin = results.features[0].geometry.x,
    ymin = results.features[0].geometry.y,
    xmax = results.features[0].geometry.x,
    ymax = results.features[0].geometry.y;

    dojo.forEach(results.features, function (feature) {
        if (feature.geometry.x > xmax) { xmax = feature.geometry.x; }
        if (feature.geometry.y > ymax) { ymax = feature.geometry.y; }
        if (feature.geometry.x < xmin) { xmin = feature.geometry.x; }
        if (feature.geometry.y < ymin) { ymin = feature.geometry.y; }
    });
    xtent = new esri.geometry.Extent(xmin, ymin, xmax, ymax, map.spatialReference);
    map.setExtent(xtent, true);
}

function highlightMonuments(results, markerType) {
    map.graphics.clear();
    var symbol = new esri.symbol.SimpleMarkerSymbol();
    symbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 255, 255, 1.0]), 3));
    symbol.setStyle(esri.symbol.SimpleMarkerSymbol[markerType]);
    symbol.setColor(new dojo.Color([0, 255, 255, 0.0])); // hollow center, fully transparent
    symbol.setSize(10);
    var geom;

    dojo.forEach(results.features, function (value) {
        geom = value.geometry;
        var graphic = new esri.Graphic(geom, symbol);
        map.graphics.add(graphic);
    });
}


Show me some love with an answer?
0 Kudos