cmv / cmv-app

CMV - The Configurable Map Viewer - A community supported open source mapping framework built with the Esri JavaScript API and the Dojo Toolkit
https://demo.cmv.io/
MIT License
325 stars 278 forks source link

example to use Arcade in a customized identify config file #961

Open ERS-Long opened 4 years ago

ERS-Long commented 4 years ago

Hi Tim,

Please see what is the issue with this function when i switched the Identify code to use Arcade.

I have a customized identify config code, the structure is something like

================================================================= define([a set of dojo modules], function (a set of names) { var formatters = { myIdentify_Method1: function(identifyResults) { //code here to prepare all the logic // //the problem is this function never got called } };

return { map: true, mapClickMode: true, mapRightClickMenu: true, identifyLayerInfos: true, identifyTolerance: 10, draggable: true, returnFieldName: true, returnUnformattedValues: true,

identifies : { layer1: { 0: { title: 'Gauges', useExpression: false, content: formatters.myIdentify_Method1 } } } })

Please help, Thanks!

tmcgee commented 4 years ago

Hello @ERS-Long

Good to hear from you!

I see you're trying to use your formatter function with Arcade to set the content of the popup. Typical usage within CMV is to call that function for a specific field like this. I highlighted line 87 also because setting useExpression: false as you have done will not use an Arcade expression. To use arcade, you would set that to true or remove it completely since true is the default,

If you do want to use Arcade expression to set the entire popup content, I am not sure if that is supported by Esri or CMV. I have never tried it and would be surprised if it works.

As far as why your function is not called at all, I seem to recall there being a CMV bug that won't allow you to set the content using a function as you have done. I'm not finding my notes about it at the moment. Will look at it further.

ERS-Long commented 4 years ago

hi Tim,

Thanks a for your reply.

Yes, I was playing with Arcade to see what the benefit we can get out of it. But i still wants to keep the old function there. For right now, i just did a work around, if i need to use Arcade, i will load the new identify widget code, if not i switch it back. Just for now.

Stay safe!