I am trying to do an example here : https://developers.arcgis.com/javascript/latest/sample-code/intro-layers/
I replace these parts:
<link rel="stylesheet" href="https://js.arcgis.com/4.31/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.31/"></script>
with my own hosted js on my laptop using XAMPP:
<link rel="stylesheet" href="http://localhost/javascript/api/4.31/esri/themes/light/main.css" />
<script src="http://localhost/javascript/api/4.31/"></script>
Note: the locally hosted JS scripts are on "http", not "https"
I add my own layer hosted on Geoportal on our company web server on this part
"const featureLayer = new FeatureLayer({" :
so it becomes like this:
const featureLayer = new FeatureLayer({
url: "https://companywebserver.com/server/rest/services/Survey/Boundary/FeatureServer/0"
});
This web server can be accessed from outside.
All links hosted on localhost (script and feature service) work correctly and can be accessed. They give out the same output as the script hosted on arcgis.com
The apps works without problem if I use the script hosted on "js.arcgis.com". The FeatureService is loaded successfully. There is popup window requesting login to the Portal item (feature service). This is because I dont use token I guess, but its fine.
But, It does not work using locally hosted JS. Here are the errors:
1). Uncaught SyntaxError: Unexpected token '<' (at VM709:1:1)
2). (index):1 Uncaught SyntaxError: Unexpected token '<' (at (index):1:1)
3). There is info on AutoClicker.JS saying "AutoClicker initilize complete"
Note: Both errors 1 & 2 point to "<!DOCTYPE html>"
Here is the screenshot about the error:
Now, to avoid those errors above, I add "type="text/JSX"" to the script tag. They now become:
<link rel="stylesheet" href="https://js.arcgis.com/4.31/esri/themes/light/main.css" type="text/JSX"/>
<script src="https://js.arcgis.com/4.31/" type="text/JSX"></script>
The first 2 errors do not appear. The warning about autoclicker still persist. But there is nothing on the display. It is just a blank white display.
The only difference between using JS hosted locally and hosted on arcgis.com is
the login popup to the Feature Service hosted on local Geoportal.
What seems to be the problems ? How can I fix this ?
Many thanks. Need some advice.