Add Layers using ArcGISDynamicMapService in JavaScript API

2335
7
11-20-2011 07:57 AM
SumanD
by
New Contributor III
Hi
I know that from ArcGIS Server Version 10.1 and Silverlight 3 onwards, the ArcGIS Server dynamic map services supports the ability to change the rendering and order or layers on the fly.

Is this functionality available in JavaScript API s as well. I am fairly new to this area and any kind of help will be appreciated
0 Kudos
7 Replies
derekswingley1
Frequent Contributor
This functionality will be in the 3.0 release of the API which will come out when 10.1 is final. We are hoping to add support for dynamic layers at an upcoming 2.x release that will work with 10.1 beta/pre-release but haven't finalized those plans yet.
0 Kudos
JeffPace
MVP Alum
This functionality will be in the 3.0 release of the API which will come out when 10.1 is final. We are hoping to add support for dynamic layers at an upcoming 2.x release that will work with 10.1 beta/pre-release but haven't finalized those plans yet.


Derek,
just out of curiosity, will the functionality exist to PREVENT this as well.  We have standards for symbols/colors,etc.. I would hate to think someone could just override it.
0 Kudos
AnthonyWarren
New Contributor
Can anyone tell me if this functionality of adding a dynamic layer was added in the 2.6 javascript api?  And if so, how it is done.  Or is this still forthcoming?

I have been unsuccessful with my own local application testing (with 10.1 beta 2) but I was able to enter a dynamic layer formatted JSON string from my server into the arcgis.com online map builder and successfully add the layer.  This the basic syntax I used
http://MyServer/agspub/rest/services/MyService/MapServer/dynamicLayer?f=json&layer={"source": {"type": "dataLayer","dataSource": {"type": "table","workspaceId": "Prototype","dataSourceName": "MyDatabase.DBO.MyFeatureClass"}}}

This thread seems to indicate that arcgis.com is using the same api http://forums.arcgis.com/threads/45458-ArcGIS.com-Interface-vs-JavaScript-API?p=155160 so I would think I should be able to do the same thing locally in my own application.

The test I tried on arcgis.com was for just a simple layer (no symbology or joins).  When I tried a JSON string with a join I could not add it this way (no error, but nothing added to the map).  However when I enter the full REST URL into my local browser to get the dynamic layer resource, the response looks correct with no errors. 

The arcgis.com testing was just to see if my JSON was correct.  Ultimately I wanted to test the performance of a dynamic layer with a table join with rendering based on the joined table attributes in my own application.  Looking at the REST documentation for dynamic layers it looks like it should be possible.

Can anyone tell me if what I'm trying to do can be done?  Or when the functionality will be available?  I seem to be close to success but I'm not quite there.

thanks
Anthony Warren
Cengea Solutions
Victoria BC
0 Kudos
JianHuang
Occasional Contributor III
Anthony,

2.6 doesn't include that functionality. We are working on it and hoping to have it in the next release.
What you described is possible even with current JS API as you can talk to REST API directly. But I would recommend to wait for the release.
The reason that arcgis.com works is that the URL that you entered returns a regular layer resource which can be added to the map as a featureLayer. The same scenario should work on your own JS API based application.
0 Kudos
JianHuang
Occasional Contributor III
Yes, you can disable dynamic layers on server side.

Derek,
just out of curiosity, will the functionality exist to PREVENT this as well.  We have standards for symbols/colors,etc.. I would hate to think someone could just override it.
0 Kudos
AnthonyWarren
New Contributor
Anthony,

2.6 doesn't include that functionality. We are working on it and hoping to have it in the next release.
What you described is possible even with current JS API as you can talk to REST API directly. But I would recommend to wait for the release.
The reason that arcgis.com works is that the URL that you entered returns a regular layer resource which can be added to the map as a featureLayer. The same scenario should work on your own JS API based application.


Thanks Jian -- I was trying to do it as a 'map' layer not a feature layer.  I used the add feature layer method  and I've been able to add both the simple and joined layer dynamically which is great.   I'll have to spend some time seeing what I can do with it now but look forward to the next api release.

Dec 23 Edit:  Jian when you say '2.6 doesn't include that functionality' what specifically are you referring to?  Is it the rendering?   I have been trying (without success) to render a dynamic layer with a table join with a unique value renderer.  I was following the example that uses the GenerateRendererTask.  It goes into the error callback function on the task 'execute'.  In the task 'constructor' I send in the dynamic layer URL.  Is this something I should be able to try and get working or is it a current limitation?  Thanks.
0 Kudos
AnthonyWarren
New Contributor
Jian when you say '2.6 doesn't include that functionality' what specifically are you referring to?  Is it the rendering?   I have been trying (without success) to render a dynamic layer with a table join with a unique value renderer.  I was following the example that uses the GenerateRendererTask.  It goes into the error callback function on the task 'execute'.  In the task 'constructor' I send in the dynamic layer URL.  Is this something I should be able to try and get working or is it a current limitation?  Thanks
0 Kudos