POST
|
I am trying to add a Feature Layer to my application that sources data from a FeatureServer URL that is hosted internally, not on an ArcGIS server. The URL requires authentication to access, either through a token parameter or an authorization header. How do I have ArcGIS JS (4.8) add the token to the URL when creating the feature layer? I have tried IdentityManager.initialize and the token property on the FeatureLayer object with no luck. Most information on how to authenticate requests is specifically for authenticating to an ArcGIS hosted resource, not something hosted elsewhere. The other tool we're using is a Node Express server hosting data from a MarkLogic database server as Feature Layers, koop-provider-marklogic. Without authentication enabled everything works fine, but that's less than ideal for security reasons.
... View more
11-30-2018
09:01 AM
|
0
|
1
|
1691
|
POST
|
Thanks Robert Scheitlin, GISP. That worked great! Spent too much time looking through the documentation and I must have skipped over the valueExpression property.
... View more
10-09-2018
11:29 AM
|
0
|
0
|
1395
|
POST
|
I'm having a problem with duplicate entries showing up in a legend from a FEMA service. Both Layer: Flood Hazard Zones (ID: 28) and Layer: General Structures (ID: 24) both have a UniqueValueRenderer which specifies multiple values that have the same Label and Symbol. When these are displayed in a legend from a LayerList all of these labels and symbols show up in the legend. Is there a better way to use these services that won't show duplicate layerInfos in the Legend or should I find another way with jQuery or something to remove the duplicates from the HTML? Below is HTML that works in the latest JS API Sandbox that replicates how I'm using them. I'd rather not have to build the legend object myself because that would be a rather large time sink for all of the other layers that are in use besides these 2 and could also break if these are updated (which is out of my control). I also didn't see a way to group these by re-creating the renderer manually. I'm still learning the API so if there is a better way to include these than putting them in a FeatureLayer I'd be happy to change that too. <!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.9</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.9/esri/css/main.css">
<script src="https://js.arcgis.com/4.9/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/layers/GroupLayer",
"esri/widgets/LayerList",
"esri/widgets/Legend"
],
function(
Map, MapView,
FeatureLayer,
GroupLayer,
LayerList,
Legend
) {
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
********************/
var floodZoneLayer = new FeatureLayer({
url: "https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/28",
title: "Flood Zone",
visible: true
});
var floodStructuresLayer = new FeatureLayer({
url: "https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/24",
title: "General Structures",
visible: true
});
var group = new GroupLayer({title: "Flood Group", layers: [floodStructuresLayer, floodZoneLayer]});
map.add(group);
var layerList = new LayerList({ view: view , style : { type: "card", layout: "auto" }});
var legend = new Legend({ view: view, style : { type: "card", layout: "stack" }});
view.ui.add(layerList, {position: "bottom-right"});
view.ui.add(legend, {position: "bottom-left"});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
10-09-2018
05:03 AM
|
0
|
2
|
1512
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|