Select a feature with the Export Web Map service

3521
9
Jump to solution
12-22-2015 04:58 AM
MustafaKocaoğlu
New Contributor

I have a javascript app without a  map.  I need a png from export web map service and one of the features(geometry type polygon) should be  selected. My code look like this:

var dynamicLayers = '[{"source":{"mapLayerId":3,"selectionObjectIds":['+ attrs.OBJECTID +'],"selectionSymbol":{"symbol":{"type":"esriSFS","style":"esriSFSSolid","color":[255,0,0,255]}}}}]';
var JsonObj = {
     "bbox": JSON.stringify(result.features[0].geometry.getExtent()/*.expand(2) */),
     "format":"png",
     "transparent": "false",
     "size":"800,600",
     "f": "pjson",
     "mapScale": "1000",
     "dynamicLayers":dynamicLayer
}

$.get(getConfigValuByName("exportMapImage"), JsonObj, function (data) {
       $("#loading").show();
       var obj = JSON.parse(data);
                 /*....*/
       $("#loading").hide();
});
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Mustafa,

  This is what I think will work in your situation:

var dynamicLayers = '[{"id":102,"source":{"type":"mapLayer","mapLayerId":3},"definitionExpression": "YOUR_OBJECTID_FIELD_NAME = '+ attrs.OBJECTID +'","drawingInfo":{"renderer": {"type":"simple", "symbol": {"type":"esriSFS","style":"esriSFSSolid","color":[0,0,255,255],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0,0,255,255],"width":1}}}}},{"id":101,"source":{"type":"mapLayer","mapLayerId":3},"drawingInfo":{"renderer": {"type":"simple", "symbol": {"type":"esriSFS","style":"esriSFSSolid","color":[201,242,208,255],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[110, 110, 110, 255],"width":1}}}}}]';

Basically you define two dynamic layer one with a definition expression for the ObjectId you want to highlight and the second if the whole layer you want one the exported image (they are the same layers). The order you add them to the dynamicLayers determines their drawing order.

View solution in original post

9 Replies
RobertScheitlin__GISP
MVP Emeritus

Mustafa,

   Have you tried to run those json parameters just using the rest endpoint in your web browser? I do not see any support for selectionObjectIds in the help documentation. Does your map service have dynamicLayers support enabled?

0 Kudos
MustafaKocaoğlu
New Contributor

Yes, i tried to run those json parameters just using the rest endpoint in my browser and my map server have dynamicLayers support enabled. I got the png but not selected my geometry.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mustafa,

   As I mentioned I can not find in the help docs where those parameters are supported. Look at my last reply for a solution that does work based on my testing.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mustafa,

  This is what I think will work in your situation:

var dynamicLayers = '[{"id":102,"source":{"type":"mapLayer","mapLayerId":3},"definitionExpression": "YOUR_OBJECTID_FIELD_NAME = '+ attrs.OBJECTID +'","drawingInfo":{"renderer": {"type":"simple", "symbol": {"type":"esriSFS","style":"esriSFSSolid","color":[0,0,255,255],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0,0,255,255],"width":1}}}}},{"id":101,"source":{"type":"mapLayer","mapLayerId":3},"drawingInfo":{"renderer": {"type":"simple", "symbol": {"type":"esriSFS","style":"esriSFSSolid","color":[201,242,208,255],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[110, 110, 110, 255],"width":1}}}}}]';

Basically you define two dynamic layer one with a definition expression for the ObjectId you want to highlight and the second if the whole layer you want one the exported image (they are the same layers). The order you add them to the dynamicLayers determines their drawing order.

KenBuja
MVP Esteemed Contributor

Is the variable used in the JSonObj incorrect? You initialize dynamicLayers but in the constructor use


"dynamicLayers":dynamicLayer 
MustafaKocaoğlu
New Contributor

Thanks

0 Kudos
MustafaKocaoğlu
New Contributor

Thank you Robert,

it works. Is it possible to let the rest of the layers visible? I mean i just want to select one feature and the other features and the other layers should be visible without changing style.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mustafa,

   I do not know of a way to do that.

0 Kudos
MustafaKocaoğlu
New Contributor

Thank you anyway.

0 Kudos