Select to view content in your preferred language

Display ArcMap Query Layer

2134
5
03-01-2012 07:11 AM
BrianCalvert
Emerging Contributor
Let me start by noting that I am new to JavaScript and I have been working with the JavaScript API for about 3 weeks now.  I am working with ArcGIS 10 Desktop and ArcGIS 10 Server.  In ArcMap, I have created a Query Layer and it is in a project along with some other shape file data.  I have published the .mxd to our ArcGIS server and the service is working.

In my application I am able to call, render, interact with the data that was a shape file data using the FeatureLayer.  That all works great, but...   I am having problems calling the layer that was created using the Query Layer.  I have tried to access it using the FeatureLayer with out success.  I have included my call below, please advise on how I can call the Query Layer.

  function initSalesPoints() {
   var SalesPointsInfoTemplate = new esri.InfoTemplate();
   SalesPointsInfoTemplate.setTitle("<b>Sale Points</b>");
       SalesPointsInfoTemplate.setContent ("<b>Listing Number</b>  ${Number_Display}<br/>"
              +"<b>Recording Date</b>  ${Selling_Date}<br/>"
              +"<b>Sale Price</b>  ${SellPrice}"
            ); 
   
   SalesPointsLayer = new esri.layers.FeatureLayer(gisServer+SalesPointsLayer_ID,{
     mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
     outFields: ["Number_Display", "Selling_Date", "SellPrice", "County"],
     opacity: 1.0,
     visible: false,
     infoTemplate: SalesPointsInfoTemplate
   });

   var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10,
       new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
       new dojo.Color([255,0,0]), 1),
       new dojo.Color([0,255,0,0.25])
   );
  
   var renderer = new esri.renderer.SimpleRenderer(symbol);
   SalesPointsLayer.setRenderer(renderer);
   map.addLayer(SalesPointsLayer);
   layerList.push(SalesPointsLayer);  // #4
  }
0 Kudos
5 Replies
derekswingley1
Deactivated User
I would start by going to your REST services directory and seeing if your features are returned when you hit the query endpoint. Here's an example using data from one of our sample servers:  http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer/0/que...

I'm suggesting this because this is how your feature layer will be requesting features. The first thing to check is that ArcGIS Server is returning features.
0 Kudos
KellyHutchins
Esri Frequent Contributor
There's an old blog post that shows an example of accessing a query layer here:

http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2010/08/30/Populate-a-combo-box-with-unique-val...

The service is no longer live so the sample doesn't run but the blog post contains an example of how to access a query layer using a feature layer.
0 Kudos
BrianCalvert
Emerging Contributor
I would start by going to your REST services directory and seeing if your features are returned when you hit the query endpoint. Here's an example using data from one of our sample servers:  http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer/0/que...

I'm suggesting this because this is how your feature layer will be requesting features. The first thing to check is that ArcGIS Server is returning features.


Thank you swingley, usining the query portion of the url provided returned results from my REST Endpoint.

Kelly,  I was just going down the path of the example you sent when my ESRI support agent gave me a call.  We started down the path you suggested but ended up with a solution without making the qurey request.

Thank You all.
0 Kudos
derekswingley1
Deactivated User
Thank you swingley, usining the query portion of the url provided returned results from my REST Endpoint.

Kelly,  I was just going down the path of the example you sent when my ESRI support agent gave me a call.  We started down the path you suggested but ended up with a solution without making the qurey request.


Glad support was able help you out. Can you post what they suggested and what you did to get your query layer to display via a feature layer?
0 Kudos
BrianCalvert
Emerging Contributor
I was not too far off in my attempt to use the FeatureLayer.  There was some confustion at first in the way that I was describing what I wanted to do.  I was not looking to querry a layer directly from my FeatureLayer call.  Instead I wanted to call a layer from our map service that was created in ArcMap using a query layer.  Once that was cleared up it was pretty straight forward.

        var featureLayer = new esri.layers.FeatureLayer(gisServer+"0",{
          mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
          outFields: ["*"]
  //        infoTemplate: infoTemplate
        });
        map.addLayer(featureLayer);

The main differences I see is that in this example, i am taking "*" for the outField and previously i was using an defined list of attributes.  This confirms a message in fiddler that was saying I was missing some attributes.
0 Kudos