POST
|
Hey, @IsmaelChivite is there a guide, video or documintation on how to combine the report service with the enterprise survey123 website? can you post the ArcGIS Online report service url?
... View more
08-25-2024
04:47 AM
|
0
|
0
|
340
|
POST
|
this is a dist file code , copy it as html file or paste the code on codepen - like the original sample its taken from. I'm using shapefile sample for a quick start so the function name and title are from the source. the code itself is edited. shapefile no longer matters when you run this sample, its csv ->analyze response >generate - breaks > add to map. use the csv I've attached or create one, did it work? did you try something else? did the analyze return a response - it should ? did the generate? - it didn't for me, i think the paraments i used are wrongly implemented .
... View more
07-18-2023
05:09 PM
|
0
|
0
|
1043
|
POST
|
I'm trying to create an add data widget with csv input. using the shapefile to feature Layer sample as a base. https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-shapefile/ the sample uses generate, and for the publishing parameters Analyze. "Callers can use the Analyze operation to generate the default publishing parameters for the source input." https://developers.arcgis.com/rest/users-groups-and-items/generate.htm I have a 1 point csv for testing. - attached the analyze works, but i think I'm not using the generate properly because I'm getting "414 Request-URI Too Large error" on such a small table. I believe the generate should return an object to automatically work with the addShapefileToMap. <!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Create a FeatureLayer from a shapefile almost there</title>
</head>
<body>
<!-- partial:index.partial.html -->
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>
Create a FeatureLayer from a shapefile | Sample | ArcGIS Maps SDK for
JavaScript 4.27
</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#mainWindow {
padding: .5em;
background-color: #fff;
}
#mainWindow p, #uploadForm {
display: block;
padding: .1em;
}
</style>
<link
rel="stylesheet"
href="https://js.arcgis.com/4.27/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.27/"></script>
<script>
require([
"esri/config",
"esri/Map",
"esri/views/MapView",
"esri/widgets/Expand",
"esri/request",
"esri/layers/FeatureLayer",
"esri/layers/support/Field",
"esri/Graphic"
], (
esriConfig,
Map,
MapView,
Expand,
request,
FeatureLayer,
Field,
Graphic
) => {
const portalUrl = "https://www.arcgis.com";
document
.getElementById("uploadForm")
.addEventListener("change", (event) => {
const fileName = event.target.value.toLowerCase();
generateFeatureCollection(fileName);
});
const map = new Map({
basemap: "dark-gray-vector"
});
const view = new MapView({
center: [-41.647, 36.41],
zoom: 2,
map: map,
container: "viewDiv",
popup: {
defaultPopupTemplateEnabled: true
}
});
const fileForm = document.getElementById("mainWindow");
const expand = new Expand({
expandIcon: "upload",
view: view,
content: fileForm
});
view.ui.add(expand, "top-right");
function generateFeatureCollection(fileName) {
let name = fileName.split(".");
// Chrome adds c:\fakepath to the value - we need to remove it
name = name[0].replace("c:\\fakepath\\", "");
document.getElementById("upload-status").innerHTML =
"<b>Loading </b>" + name;
// define the input params for generate see the rest doc for details
// https://developers.arcgis.com/rest/users-groups-and-items/generate.htm
const params = {
name: name,
targetSR: view.spatialReference,
maxRecordCount: 1000,
enforceInputFileSizeLimit: true,
enforceOutputJsonSizeLimit: true
};
// generalize features to 10 meters for better performance
params.generalize = true;
params.maxAllowableOffset = 10;
params.reducePrecision = true;
params.numberOfDigitsAfterDecimal = 0;
let myContent = {
filetype: "csv",
publishParameters: JSON.stringify(params),
f: "json"
};
////////////////////////////// analyze csv
request(portalUrl + "/sharing/rest/content/features/analyze", {
query: myContent,
body: document.getElementById("uploadForm"),
responseType: "json"
})
.then((response) => {
console.log("analyze")
console.log(response);
////////create new query for generate with response from analyze
let myContent = {
filetype: "csv",
publishParameters: JSON.stringify(response.data.publishParameters),
f: "json"
};
/////////////////////////////////////generate
request(portalUrl + "/sharing/rest/content/features/generate", {
//method:"post",
query: myContent,
body: response.data.records,
responseType: "json"
})
.then((response) => {
console.log("generate")
console.log(response);
const layerName = response.data.publishParameters.name;
//response.data.featureCollection.layers[0].layerDefinition.name;
document.getElementById("upload-status").innerHTML =
"<b>Loaded: </b>" + layerName;
addShapefileToMap(response.data);
})
.catch(errorHandler);
})
.catch(errorHandler);
}
///////////////////////////////////////////// all this inside then
function errorHandler(error) {
console.log(error.message)
document.getElementById("upload-status").innerHTML =
"<p style='color:red;max-width: 500px;'>" + error.message + "</p>";
}
function addShapefileToMap(featureCollection) {
console.log("adding layer")
// add the shapefile to the map and zoom to the feature collection extent
// if you want to persist the feature collection when you reload browser, you could store the
// collection in local storage by serializing the layer using featureLayer.toJson()
// see the 'Feature Collection in Local Storage' sample for an example of how to work with local storage
let sourceGraphics = [];
const layers = featureCollection.layers.map((layer) => {
const graphics = layer.featureSet.features.map((feature) => {
return Graphic.fromJSON(feature);
});
sourceGraphics = sourceGraphics.concat(graphics);
const featureLayer = new FeatureLayer({
objectIdField: "FID",
source: graphics,
fields: layer.layerDefinition.fields.map((field) => {
return Field.fromJSON(field);
})
});
return featureLayer;
// associate the feature with the popup on click to enable highlight and zoom to
});
map.addMany(layers);
view.goTo(sourceGraphics).catch((error) => {
if (error.name != "AbortError") {
console.error(error);
}
});
document.getElementById("upload-status").innerHTML = "";
}
});
</script>
</head>
<body>
<div id="mainWindow">
<div>
<div style="padding-left:4px;">
<p>
Download shapefile from
<a
href="https://bsvensson.github.io/various-tests/shp/drp_county_boundary.zip"
>here.</a
>
</p>
<p>Add a zipped shapefile to the map.</p>
<p>
Visit the
<a
target="_blank"
href="https://doc.arcgis.com/en/arcgis-online/reference/shapefiles.htm"
>Shapefiles</a
>
help topic for information and limitations.
</p>
<form enctype="multipart/form-data" method="post" id="uploadForm">
<div class="field">
<label class="file-upload">
<span><strong>Add File</strong></span>
<input type="file" name="file" id="inFile" />
</label>
</div>
</form>
<span
class="file-upload-status"
style="opacity:1;"
id="upload-status"
></span>
<div id="fileInfo"></div>
</div>
</div>
</div>
<div id="viewDiv"></div>
</body>
</html>
<!-- partial -->
</body>
</html>
... View more
07-17-2023
01:12 PM
|
31
|
3
|
1145
|
DOC
|
Hi Robert Scheitlin, GISP, Thanks again for the great work with that widget! I'm interested with customizing the window content but I found it more complicated than expected.. Is it possible to add a button / link within the popup window that turns on a different layer + changes the selection to a different feature? (run a query task on another layer) I tried implementing a javascript snippet in the configurations of the popup window through the web map but I couldn't see how i can select other layers when im in the scope of the window popup.. I assume that manipulating the displayed data of the popup requires a cusome template of the popup window? or can you think of a better way of doing this? Regards, Shay.
... View more
09-27-2018
01:59 AM
|
0
|
0
|
4331
|
POST
|
No it's just a fresh idea that I was hoping to find a quick answer for.
... View more
06-21-2018
06:05 AM
|
0
|
1
|
1373
|
POST
|
I'd be happy to know if you received a clear answer by now..
... View more
06-21-2018
05:56 AM
|
0
|
3
|
1373
|
POST
|
Hello, I'm not really sure if this is the right spot for this. If not, I'll be happy to move it. I have created a P.O.C in Angular with the help of the brilliant tutorial code in github. I have changed the basemap to my own tile service, but since we are using a different SpatialReference, problems started to come up quickly. I discovered that when addressing the center property of the basemap, by default, it takes either an array of two numbers [x,y], or a PointProperties datatype... either way, SpatialReference is out of the picture and that is wrong. The way I managed to solve this was by passing a json object as follow - { x:..., y:...., SpatialReference: 2039 } This code luckily works, but I'm getting an error on the data type, since it's not documented as supported inside the API. Is there a way to pass this as a change recommendation to ESRI?? SpatialReference is super important for some countries and the difference between supporting it and not in most cases, for us, it's show stopper. Most of ESRI's new products will never be in use for us because they lack of support with the relevant SpatialReference.. Regards, Shay.
... View more
06-18-2018
07:37 AM
|
0
|
0
|
656
|
POST
|
Hi, I came across with this problem as well in my local installation of Portal for ArcGIS and managed to fix it. you can solve this bug manually by going to the local library where the JS API is located at (....\arcgis_js_api\library\), there should be a library called xstyle and there should be a file there named css.js In that file, search for the following text - a&&"none"!=a and replace it with - a&&"none"!=a&&"normal"!=a in the api library, there might be a second version of this file, so it's just best to run a texet search on all files under that api location. Hope that helps. Cheers, Shay.
... View more
06-14-2018
03:55 AM
|
2
|
0
|
1244
|
POST
|
I've noticed that this discussion is related to AGOL, but I came across with this problem as well in my local installation of Portal for ArcGIS and managed to fix it. So for those who are using the on-premise version, this bug is manually solvable by going to the local library where the JS API is located at (....\arcgis_js_api\library\), there should be a library called xstyle and there should be a file there named css.js In that file, search for the following text - a&&"none"!=a and replace it with - a&&"none"!=a&&"normal"!=a in the api library, there might be a second version of this file, so it's just best to run a texet search on all files under that api location. Hope that helps anyone. Cheers, Shay.
... View more
06-14-2018
03:45 AM
|
0
|
0
|
943
|
DOC
|
I need such a feature as well. would be great to have it added
... View more
08-21-2017
01:36 AM
|
0
|
0
|
5103
|
POST
|
Did you ever tried using a different client instead of arcpy.ArcSDESQLExecute to query the database? from different posts I found, people says it's not a good idea but I didn't tried it. Shay.
... View more
08-10-2017
03:21 AM
|
0
|
0
|
1669
|
POST
|
I'm having the exact same problem with older versions. ArcGIS Server 10.4.1 and MSSQL 2012. I did cast to begin with but it slows down the query and the script takes 7 minutes to finish instead of a few seconds!! Is there a bug for this in ESRI?? Shay.
... View more
08-10-2017
03:14 AM
|
0
|
0
|
1669
|
DOC
|
Hi Robert Scheitlin, GISP, I took the old widget (above, which does not work anymore..) and changed it a bit to assemble a link with the relevant coordinates once you click a point on the map and then a google street view is opened on a seperate tab in the browser. I believe this is completely legal? Also, I noticed it's still possible to show a popup in the widget window as long as you use a personal token during the usage but I didn't invested more time on doing this this at this point. Maybe in the future - Street View containers | Google Maps JavaScript API | Google Developers I thought i'll upload the widget with my changes but I'm still not completely certain that's legit.. so I thought I'll consult here with you first..? Regards, Shay.
... View more
07-17-2017
04:02 AM
|
0
|
0
|
7523
|
POST
|
Hi Joel, Here are lines 50-70 of the code: array.forEach(values, function (val) {
if (text !== "") {
text += '<br>';
}
if (['GPLong', 'GPDouble', 'GPString', 'GPBoolean']
.some(function (s) { return /*param.dataType.includes(s);*/ (param.dataType.indexOf(s) >= 0) })) {
text += utils.sanitizeHTML(val);
} else if (/*param.dataType.includes('GPLinearUnit')*/(param.dataType.indexOf('GPLinearUnit') >= 0)) {
text += val.distance + ' ' + val.units;
} else if (/*param.dataType.includes('GPDate')*/(param.dataType.indexOf('GPDate') >= 0)) {
text += new Date(val).toLocaleTimeString();
} else if (/*param.dataType.includes('GPRecordSet')*/(param.dataType.indexOf('GPRecordSet') >= 0)) {
text += 'table';
} else if (/*param.dataType.includes('GPDataFile')*/(param.dataType.indexOf('GPDataFile') >= 0) || /*param.dataType.includes('GPRasterDataLayer')*/(param.dataType.indexOf('GPRasterDataLayer') >= 0)) {
if (val.url) {
text += '<a target="_blank" href="' + val.url + '">' + val.url + '</a>';
} else {
text += param.paramName + ': null';
}
}
});
Hope it helps. Regards, Shay.
... View more
07-17-2017
03:30 AM
|
2
|
0
|
626
|
DOC
|
Hi, I must admit I thought this is a different post (I wrote a post on how to acomplish this in the filter of a web appbuild). Maybe it doesn't know the variable because of the layer type but that's a wild guess really. Good luck. Shay.
... View more
07-10-2017
08:36 AM
|
0
|
0
|
19002
|
Title | Kudos | Posted |
---|---|---|
31 | 07-17-2023 01:12 PM | |
1 | 03-14-2016 09:14 AM | |
1 | 03-21-2016 10:18 AM | |
1 | 05-29-2017 07:39 AM | |
1 | 09-23-2015 09:15 AM |
Online Status |
Offline
|
Date Last Visited |
08-25-2024
12:53 PM
|