POST
|
Thank you Richard. Using the portal.queryItems functionality from the arcgis.Portal module worked great. For those interested in the code (ArcGIS JS API 4.14): var authInfo = new OAuthInfo({
appId: myAppID,
popup: false
});
esriId.registerOAuthInfos([authInfo]);
var portal = new Portal();
portal.authMode = "immediate";
portal.load().then(function(){
var queryParams = {
query: 'owner:' + portal.user.username + ' AND title:"P*"',
sortField: "title"
};
portal.queryItems(queryParams);
});
... View more
04-06-2020
11:43 AM
|
2
|
0
|
1187
|
POST
|
How do I get my REST query to return privately owned (by me) items that are hosted on my organization's ArcGIS Online Portal? My code uses ArcGIS REST JS to create a REST search query. The query successfully returns any items of mine that I have publicly shared, but not the items that are private. I authenticate my credentials in the script using the Identity Manager from the ArcGIS API for JavaScript, and I have no problems accessing my private layers in other ways through the script. Here's the relevant snippet: // Authentication
var authInfo = new OAuthInfo({
appId: myAppID,
popup: false
});
esriId.registerOAuthInfos([authInfo]);
...
// REST JS Query
const query = new arcgisRest.SearchQueryBuilder()
.match(myUserName)
.in("owner")
.and()
.match("*")
.in("title")
arcgisRest.searchItems(query); Again, this query successfully returns my public but not my private items. Is there a way to pass my authentication along with the query? Any help would be appreciated.
... View more
03-26-2020
01:54 PM
|
1
|
3
|
1304
|
POST
|
I am creating a browser app that integrates the ArcGIS API for Javascript, and ArcGIS Rest JS in order to allow users to create and edit Feature Layers hosted on ArcGIS Online. I am able to create a hosted Feature Layer that appears in my 'Contents' on ArcGIS Online, but I am unable to add this layer to my WebMap. Here is the relevant function below, called by a widget when clicked: function createSite() {
// pass credentials of auth session from JS API to Rest JS
esriId.getCredential("https://arcgis.com/sharing/rest/")
.then(cred => {
const session = new arcgisRest.UserSession.fromCredential(cred);
// create the item
arcgisRest.createFeatureService({
item: {
name: sitename,
capabilities: "Create, Delete, Query, Update",
},
authentication: session
})
//get url of newly created feature service
.then(response =>{
var newURL = response.encodedServiceURL;
// add service definition
arcgisRest.addToServiceDefinition(newURL, {
authentication: session,
layers: [ {name: "thisLayer",
type: "Feature Layer",
geometryType: "esriGeometryPoint",
fields: [
{
name: "FID",
type: "esriFieldTypeInteger",
actualType: "int"
}
]
} ]
});
});
});
// refresh layers on map view - remove all, query, and load again
map.layers.removeAll();
loadLayers();
}; Again, this successfully creates a Feature Layer in my ArcGIS Online Contents. However, when loadLayers() is called - which successfully loads the other Feature Layers from my account into the WebMap - the new layer does not appear. Likewise, when I try to open this new layer directly in the 'Map Viewer' on ArcGIS Online, nothing happens and the layer does not appear in the contents pane of the map. Is this a problem with the layer details of the new Feature Layer? In other words, are there parameters and/or fields that I need to include in the addToServiceDefinition call in order for the newly created Feature Layer to have a valid format? Or is it possible to specify at creation that this new Feature Layer should mimic a template, such as the 'Points' template that is available when creating Feature Layers manually on ArcGIS Online? In short, I need the new Feature Layer I create to be valid and able to display and edit in the WebMap viewer. Any help with this would be greatly appreciated. Thanks.
... View more
03-11-2020
10:30 AM
|
0
|
1
|
636
|
POST
|
Thank you very much. This may be a bit outside the scope of this question, but I believe I can mimic the functionality I'm looking for by using the arcgis-rest-js modules to createItem() in create a new feature layer in ArcGIS Online, then use the javascript api's featureLayer.applyEdits() functionality to add in Graphics objects as new features. Can you/anyone confirm if this could work as intended?
... View more
12-19-2019
12:26 PM
|
0
|
0
|
451
|
POST
|
In my code, I have created a new FeatureLayer using client-side graphics: var fl = new FeatureLayer({
source: array_of_Graphics_Objects,
...
});
map.add(fl); The FeatureLayer is created and displaying successfully in the MapView. I would now like to publish it to my ArcGIS Online account so the contents are saved as a hosted FeatureLayer. Any help on how to go about this would be appreciated. Thank you.
... View more
12-16-2019
07:38 AM
|
0
|
2
|
520
|
POST
|
That was it - it needed an array. Thank you very much for your help.
... View more
12-15-2019
04:16 PM
|
1
|
1
|
3403
|
POST
|
I'm attempting to manually create a new FeatureLayer from client side Graphics. I cannot figure out where I am going wrong, but the FeatureLayer is not visible on the map. My code is below: <!DOCTYPE html>
<html>
<head>
<title>CreateLayer</title>
<style>
html,
body,
#ViewMap_div {
margin: auto;
height: 95%;
width: 95%;
}
</style>
<script src="https://js.arcgis.com/4.13/"></script>
<link rel="stylesheet" href="https://js.arcgis.com/4.13/esri/themes/light/main.css"/>
<script>
require([
"esri/Map",
"esri/WebMap",
"esri/views/MapView",
"esri/Graphic",
"esri/layers/GraphicsLayer",
"esri/layers/FeatureLayer",
"esri/geometry/Point",
], function(Map, WebMap, MapView, Graphic, GraphicsLayer, FeatureLayer, Point){
// create the map view
var map = new WebMap({
basemap: 'hybrid'
});
var view = new MapView({
container: "ViewMap_div",
map: map,
center: [-76, 37],
zoom: 10,
extent: {
spatialReference: 4326
}
});
var pointGL = new Graphic({
geometry: {
type: "point",
longitude: -76,
latitude: 37
},
attributes: {
ObjectID: 1,
ProjectName: 'ProjA',
SiteName: 'SiteA'
}
});
var fl = new FeatureLayer({
source: pointGL,
renderer: {
type: "simple",
symbol: {
type: "simple marker",
color: "green",
outline: {
color: "red",
width: 2
}
}
},
fields: [
{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
},
{
name: "ProjectName",
alias: "ProjectName",
type: "string"
},
{
name: "SiteName",
alias: "SiteName",
type: "string"
}
],
objectIDField: "ObjectID"
});
map.add(fl);
/* create GraphicsLayer for the pointGL Graphic
var gl = new GraphicsLayer({
graphics: pointGL
});
map.add(gl);
*/
});
</script>
</head>
<body>
<div id = "ViewMap_div"></div>
</body>
</html> If you un-comment the section at the end creating a GraphicsLayer from the pointGL Graphic, it is clear that the Graphic is formed properly. For some reason, the new FeatureLayer is not being created, or is not displaying on the map. The ultimate goal is to take user-defined lat/long coordinates, create a Graphic from them, then create a new FeatureLayer from that. If someone could point me in the right direction, I'd really appreciate it. Thank you.
... View more
12-13-2019
01:35 PM
|
1
|
3
|
4072
|
Title | Kudos | Posted |
---|---|---|
1 | 12-13-2019 01:35 PM | |
1 | 03-26-2020 01:54 PM | |
2 | 04-06-2020 11:43 AM | |
1 | 12-15-2019 04:16 PM |
Online Status |
Offline
|
Date Last Visited |
01-22-2021
03:57 PM
|