1

I am building an app using javascript, google maps v2 and ESRI 10.1. I have a DynamicMapServiceLayer and a single layer in my ESRI map service. I dynamically show or hide features on the layer using the ESRI setLayerDefinitions function based on filter values selected by the user at runtime.

When the user clicks on the map I use the ESRI IdentifyTask object to find what the user clicked on. I want to show an infowindow for the feature the user clicked on. My code is sort of working but it opens infowindows for features that are filtered out (not visible) on the layer.

How can I check to see if the user clicked on a visible feature and stop opening infowindows for hidden features? Or how can I get IdentifyTask to stop including hidden features in the response object it returns?

This is my identifyParameters task invoke set up

// set the identify parameters
var identifyParameters = new esri.arcgis.gmaps.IdentifyParameters();
identifyParameters.geometry = latLng; // where the user clicked on the map
identifyParameters.tolerance = 3;
identifyParameters.layerIds = [OUTAGES_LAYER];
identifyParameters.layerOption = 'all';
identifyParameters.bounds = map.getBounds();
var mapSize = map.getSize();
identifyParameters.width = mapSize.width;
identifyParameters.height = mapSize.height;

// execute the identify operation
identifyTask.execute(identifyParameters, function(response, error) { 
    if (hasErrorOccurred(error)) return;
    addResultToMap(response, latLng);
});

UPDATE

I have upgraded to Google maps v3. Now the identify parameters support passing layerdef information as follows below. For example I can limit the identify operation to those features where FISCAL_YEAR = 2014. My problem is solved.

function identify(evt) {
    dynamicMap.getMapService().identify({
        'geometry': evt.latLng,
        'tolerance': 3,
        'layerIds': [12],
        'layerOption': 'all',
        'layerDefs': {12 : 'FISCAL_YEAR = 2014'},
        'bounds': map.getBounds(),
        'width': map.getDiv().offsetWidth,
        'height': map.getDiv().offsetHeight
    }, function(results, err) {
        if (err) {
            alert(err.message + err.details.join('\n'));
        } else {
            addResultToMap(results, evt.latLng);
        }
    });
}
  • Are you including the layer definitions in your IdentifyTask? – Juffy Jun 07 '13 at 05:11
  • No. Sounds like I should though. I've added my identifyTask setup to the post above. Where and how should I include the layer definitions? – Darcy Dommer Jun 07 '13 at 17:21
  • Hmm...oh, right. The IdentifyTask won't let you do that. How useful. Maybe look at doing a QueryTask instead (which allows you to specify SQL-like conditions in the `.where` clause) and constructing the infowindow from the results? – Juffy Jun 08 '13 at 06:20
  • Is there a way to get the queryTask to use the graphic symbols I've set up in the layer? I was using layerdefs to hide/show the features. Instead, if I use a queryTask, I'd like the features returned by the query to use their graphics from the layer config, not the default markers. – Darcy Dommer Jun 11 '13 at 06:37

0 Answers0