I'm playing around with the Javascript API for ArcGIS and wanted to use a feature layer from my Enterprise ArcGIS Online account. The script is quite simple, basically, create a map and add the feature layer. When I launch the webpage, the base map is populated and then I get a prompt to log into ArcGIS (see image below). I enter my enterprise credentials and it it tells me they are incorrect. My assumption is, that it's looking for credentials for a regular ArcGIS Online account (www.arcgis.com) as opposed to my enterprise account. So, my question is, how would I configure my Javascript to prompt me to log into my enterprise account. For reference, here is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Intro to FeatureLayer - 4.10</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.10/esri/css/main.css">
<script src="https://js.arcgis.com/4.10/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer"
],
function(
Map, MapView,
FeatureLayer
) {
var map = new Map({
basemap: "hybrid"
});
var view = new MapView({
container: "viewDiv",
map: map,
extent: { // autocasts as new Extent()
xmin: -9177811,
ymin: 4247000,
xmax: -9176791,
ymax: 4247784,
spatialReference: 102100
}
});
/********************
* Add feature layer
********************/
// Sample Feature Layers
var featureLayer = new FeatureLayer({
url: "https://services6.arcgis.com/ubm4tcTYICKBpist/arcgis/rest/services/MineralPlacerCoalTitlesService3/FeatureServer"
});
map.add(featureLayer);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
Mike,
The url you are using is Server6 from ESRI so you will have to use an AGOL login account. If the url was from your own on premise Portal the you could use your enterprise Portal account.
Thanks for the response Robert. Regardless of the Server6 portion of the URL, we use an enterprise login to access our AGOL account. My enterprise account is where that layer is being hosted. When I enter my enterprise login credentials, it does not accept them so I need to find out how to make that happen.
Mike,
I am not familiar with this enterprise account login that you are referring to. So I will bow out and let someone familiar with this chime in.
Fair enough. For your reference, when you go to sign into AGOL on the sign in page (https://www.arcgis.com/home/signin.html ), there is a button at the bottom to log into an enterprise account as opposed to a personal account (along with the ability to sign in using Facebook or Google). The enterprise log in redirects you to to your organizational account.
Other than needing to log in, your URL is to the Service root (missing a layer id after FeatureServer/). FeatureLayers point to individual layers in the service, so maybe it should be