Hi All,
See below for part of html using 3.2 javascript libraries, sample code from https://developers.arcgis.com/javascript/3/jssamples/search_suggestiontemplate.html
My featurelayer is from my ArcGIS online
var search = new Search({ sources: [{ featureLayer: new FeatureLayer("https://services1.arcgis.com/BZNs0xaSHDSi4V6G/arcgis/rest/services/postcodes/FeatureServer/0",
When I run the code, it ask to enter arcgisonline username and password. when I do this, it says incorrect username and password.
This is the same username and password, I would have used to login in directly in my ArcGIS account.
Solved! Go to Solution.
problem resolved thank you
Hi Henry,
Try replacing your service URL with the following:
https://sampleserver6.arcgisonline.com/arcgis/rest/services/SaveTheBay/FeatureServer/0
The username/password is:
user1/user1
If this passes through successfully, this will ensure you're code is correct and something is not authenticating with your service correctly.
Hi
I did change the service to
https://sampleserver6.arcgisonline.com/arcgis/rest/services/SaveTheBay/FeatureServer/0
The username/password is:
user1/user1
It seems to work accepted username/password.But how to I access my
("https://services1.arcgis.com/BZNs0xaSHDSi4V6G/arcgis/rest/services/postcodes/FeatureServer/0 on my ArcGIS Online?
Thanks, for your help
Can you share the service with a Group in ArcGIS Online and invite my username (jskinner_CountySandbox) to this Group? I can then see if I am able to see if I am able to access this service through the API sample.
Hi Jake,
I have sent you the invite.
Thanks
Is the layer added a CSV table? I don't see a service URL associated with the point layer in the web map you shared.
sorry check again
Thanks, the feature service is there now. Try unsharing it with 'Everyone'. I'm not being prompted for credentials.
ok removed sharing with everyone
Here is what I have. It works successfully. Make sure you username capitalization is correct. For example, my username is jskinner_CountySandbox. The following fails, though: jskinner_countysandbox
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>Search with Suggestion Template</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.20/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.20/esri/css/esri.css">
<style>
html,
body,
#map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#search {
display: block;
position: absolute;
z-index: 2;
top: 20px;
left: 74px;
}
</style>
<script src="https://js.arcgis.com/3.20/"></script>
<script>
require([
"esri/map", "esri/dijit/Search", "esri/layers/FeatureLayer", "esri/InfoTemplate", "dojo/domReady!"
], function (Map, Search, FeatureLayer,InfoTemplate) {
var map = new Map("map", {
basemap: "gray",
center: [-0.1265, 51.5099], // lon, lat
zoom: 10
});
var search = new Search({
sources: [{
featureLayer: new FeatureLayer("http://services7.arcgis.com/uE69mPI6U3rpSmCT/arcgis/rest/services/postcodesS/FeatureServer/0", {
outFields: ["*"],
infoTemplate: new InfoTemplate("Post Code", "Post Code: ${Postcode_3}</br>")
}),
outFields: ["Postcode_3"],
displayField: "Postcode_3",
suggestionTemplate: "${Postcode_3}",
name: "Post Code",
placeholder: "example: IG11 9XR",
enableSuggestions: true
}],
map: map
}, "search");
search.startup();
});
</script>
</head>
<body>
<div id="search"></div>
<div id="map"></div>
</body>
</html>