<!-- ArcGIS JS 4 --> <script src="https://js.arcgis.com/4.10/"></script> <script> require([ // ArcGIS "esri/WebMap", "esri/views/MapView",
The require method is typically used with Node.js but in this case looks like it's supposed to be defined within the dojo library
This isn't something I've worked with before, but can you confirm that the dojo libraries are valid? But I'm also not really sure if you need those for just the Calcite maps. This may be a question better suited for Esri is possible, but I'll try to look into this more.
Yes... focusing on this basic sample by ESRI:
You can see that require can be used out the box with only this script tag <script src="https://js.arcgis.com/4.10/"></script>.
It's included in esri scripts by default.
I add <script src="https://js.arcgis.com/4.10/"></script> to the custom symbol's template, however PI Vision keeps saying require is not defined.
I guess this has to do with load timing or it's conflicting with PI Vision referenced libraries... because just after the custom symbol finishes loading, if I type require in Chrome's console, I see that require is a valid function.
Thanks Kelsey for your reply.
I managed to get it working by editing PI Vision ASP.NET MVC application Index.cshtml view file located in this path:
After all the Scripts.Render calls, I added the necessary ESRI ArcGIS script reference.
require is now working as expected.
Note: the async keyword in the script tag is mandatory.
This is good news. However I challenge the OSIsoft PI Vision team to make this possible in future releases. There is the danger that they overwrite Index.cshtml.
Hi Mario, see my other reply on this thread for info on how adding 3rd party libraries is supported without editing .cshtml files.
4 of 4 people found this helpful
We usually recommend adding 3rd party libraries by downloading them and placing them in the PIVision\Scripts\app\editor\symbols\ext\libraries folder. JS files in this folder will be bundled and loaded alongside your custom symbols.
In your case, you would need to save the file from its CDN URL (https://js.arcgis.com/4.10/) and place it in that libraries folder. The name should not affect the loading, so you can name it something like arcgis.4.10.js.
Adding libraries in this manner avoids needing to edit any .cshtml files, which we recommend against.
Before posting this question I tried many approaches to handle the problem... including the one you mention: add external libraries to the ext\libraries folder. This is even mentioned in the course Customizing PI Vision with Extensibility.
However this method did not work. I got a different error in Chrome console: multipleDefine.
You see: I got the full JS file from https://js.arcgis.com/4.10/ (1.4 MB), named it esriarcgis4.10.js and added it to the ext\libraries folder. It's being loaded but gives a lot of errors... this is probably some sort of conflict related to the time the files are loaded in PI Vision.
The only way I got the code working was doing the unrecommended way I posted in my previous post in this thread.