Select to view content in your preferred language

Passing Attribute Value to Variable

2092
10
Jump to solution
05-01-2014 07:22 AM
LeviRoberts
Regular Contributor
We are trying to set up a simple application that only uses one layer. This layer is a grid for a mapbook. We want users to be able to click one of the grid features and it open a pdf on a separate window. The only thing I'm hung up on currently is trying to grab an attribute value and pass it to a variable. One of the attributes for the feature is the URL to the PDF.

var mapBook = new FeatureLayer("[Webservice]", {  mode: FeatureLayer.MODE_SNAPSHOT  });  map.addLayer(mapBook);  mapBook.on("click", function(evt) {  var url = [Need to pass attribute value here];         window.open(url);  });


Do I need to use Query or Identify task? Or is there something else?
0 Kudos
10 Replies
JakeSkinner
Esri Esteemed Contributor
1.) Do you have to use a FeatureLayer to achieve this functionality? 

You would have to implement another workflow to do this with a dynamic map service layer since the esri/layers/ArcGISDynamicMapServiceLayer module does not have a 'click' event.

2.) Can you call the data another way as there is by default a 1000  feature limit (This can be increased but it takes a toll on application  performance)?

In your original code, you are using MODE_SNAPSHOT to load your feature layer.  In snapshot mode, the feature layer retrieves all the features from the  associated layer resource and displays them as graphics on the client.

You should use MODE_ONDEMAND.  In on-demand mode, the feature layer retrieves features from the server when needed.

For more information see the following link:
https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html
0 Kudos