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(); });
Solved! Go to Solution.
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.
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?
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.
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.
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.
Is the variable used in the JSonObj incorrect? You initialize dynamicLayers but in the constructor use
"dynamicLayers":dynamicLayer
Thanks
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.
Mustafa,
I do not know of a way to do that.
Thank you anyway.