Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

442 lines
18 KiB

// $( "#dynamic-header" ).load( "pages/header.html" );
// $( "#dynamic-main" ).load( "pages/body.html" );
$(document).ready(function () {
require([
"esri/config",
"esri/WebMap",
"esri/views/MapView",
"esri/widgets/Home",
"esri/widgets/LayerList",
"esri/layers/GraphicsLayer",
"esri/Graphic",
"esri/rest/support/LinearUnit",
"esri/rest/geoprocessor",
], (esriConfig, WebMap, MapView, Home, LayerList, GraphicsLayer, Graphic, LinearUnit, geoprocessor) => {
esriConfig.portalUrl = "https://dev.gisportal.id/portal";
const gpUrl = "https://dev.gisportal.id/server/rest/services/mfajri/Buffer_Sample_Geoprocessing/GPServer/Buffer";
const webmap = new WebMap({
portalItem: {
id: "60994025213a4874bdb2e39503c72407"
}
});
const view = new MapView({
container: "content",
map: webmap,
zoom: 16,
center: [106.840837, -6.294844],
});
let polylineAtt = {
Name: "Buffer Area",
Owner: "MCF"
};
const graphicsLayer = new GraphicsLayer();
let homeButton = new Home({
view: view,
container: "HomeButton"
});
let layerList = new LayerList({
view: view,
listItemCreatedFunction: (event) => {
// console.log(event);
const item = event.item;
if (item.layer.type != "group") {
// don't show legend twice
item.panel = {
content: "legend",
open: true
};
}
}
});
view.ui.add(layerList, {
position: "top-right"
});
const fillSymbol = {
type: "simple-fill",
color: [168, 0, 0, 0.17],
outline: null
};
document.getElementById('procces').addEventListener('click', e => {
CLipnBuffer()
})
const CLipnBuffer = function() {
graphicsLayer.removeAll();
let radius = document.getElementById("radiusDistance").value;
let unit = document.getElementById("Unit").value;
const params = {
Pipeline_Inspection: {
"displayFieldName": "",
"geometryType": "esriGeometryPoint",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"fields": [
{
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID"
},
{
"name": "globalid",
"type": "esriFieldTypeGlobalID",
"alias": "GlobalID",
"length": 38
},
{
"name": "easting",
"type": "esriFieldTypeDouble",
"alias": "EASTING"
},
{
"name": "northing",
"type": "esriFieldTypeDouble",
"alias": "NORTHING"
},
{
"name": "anomaly_category",
"type": "esriFieldTypeString",
"alias": "ANOMALY_CATEGORY",
"length": 255
},
{
"name": "functional_location",
"type": "esriFieldTypeString",
"alias": "FUNCTIONAL_LOCATION",
"length": 500
},
{
"name": "anomaly_name",
"type": "esriFieldTypeString",
"alias": "ANOMALY_NAME",
"length": 255
},
{
"name": "anomaly_code",
"type": "esriFieldTypeString",
"alias": "ANOMALY_CODE",
"length": 100
},
{
"name": "sap_notification",
"type": "esriFieldTypeString",
"alias": "SAP_NOTIFICATION",
"length": 255
},
{
"name": "anomaly_reff_number",
"type": "esriFieldTypeString",
"alias": "ANOMALY_REFF_NUMBER",
"length": 100
},
{
"name": "anomaly_close",
"type": "esriFieldTypeString",
"alias": "ANOMALY_CLOSE",
"length": 10
},
{
"name": "anomaly_date_created",
"type": "esriFieldTypeDate",
"alias": "ANOMALY_DATE_CREATED",
"length": 8
},
{
"name": "anomaly_created_by",
"type": "esriFieldTypeString",
"alias": "ANOMALY_CREATED_BY",
"length": 100
},
{
"name": "anomaly_desc",
"type": "esriFieldTypeString",
"alias": "ANOMALY_DESC",
"length": 255
},
{
"name": "anomaly_risk",
"type": "esriFieldTypeString",
"alias": "ANOMALY_RISK",
"length": 100
},
{
"name": "anomaly_status",
"type": "esriFieldTypeString",
"alias": "ANOMALY_STATUS",
"length": 50
},
{
"name": "anomaly_comment",
"type": "esriFieldTypeString",
"alias": "ANOMALY_COMMENT",
"length": 500
},
{
"name": "action_assign_to",
"type": "esriFieldTypeString",
"alias": "ACTION_ASSIGN_TO",
"length": 100
},
{
"name": "action_comment",
"type": "esriFieldTypeString",
"alias": "ACTION_COMMENT",
"length": 500
},
{
"name": "kp",
"type": "esriFieldTypeString",
"alias": "KP",
"length": 255
},
{
"name": "survey_date",
"type": "esriFieldTypeDate",
"alias": "SURVEY_DATE",
"length": 8
},
{
"name": "status_validated",
"type": "esriFieldTypeString",
"alias": "Status Validated",
"length": 255
},
{
"name": "created_date",
"type": "esriFieldTypeDate",
"alias": "created_date",
"length": 8
},
{
"name": "created_user",
"type": "esriFieldTypeString",
"alias": "created_user",
"length": 255
},
{
"name": "last_edited_date",
"type": "esriFieldTypeDate",
"alias": "last_edited_date",
"length": 8
},
{
"name": "last_edited_user",
"type": "esriFieldTypeString",
"alias": "last_edited_user",
"length": 255
}
],
"features": [
{
"attributes": {
"OBJECTID": 809,
"EASTING": 479156.0,
"NORTHING": 9864462.0,
"ANOMALY_CATEGORY": "Row Walking Survey",
"FUNCTIONAL_LOCATION": "HDL/CPA /OIL/TRANS/8_CPA_TO_SNP",
"ANOMALY_NAME": "Corrosion Eviden",
"ANOMALY_CODE": "RWW-CE",
"SAP_NOTIFICATION": null,
"ANOMALY_REFF_NUMBER": "RWW-CE-8",
"ANOMALY_CLOSE": "No",
"ANOMALY_DATE_CREATED": 1678161600000,
"ANOMALY_CREATED_BY": "Rascal",
"ANOMALY_DESC": "Test drive",
"ANOMALY_RISK": "1 (High) - Immediate Action",
"ANOMALY_STATUS": "Open",
"ANOMALY_COMMENT": "No comment aku",
"ACTION_ASSIGN_TO": "PO/OSF/INS/PIM",
"ACTION_COMMENT": null,
"KP": null,
"SURVEY_DATE": 1678161600000,
"STATUS_VALIDATED": "Validated",
"STATUS_REVIEW": null,
"REVIEWED_BY": null,
"GlobalID": "{0AC28FE4-B997-4B36-A96F-F72AAA38E013}"
},
"geometry": {
"x": 116.81264485400004,
"y": -1.2262399559999722
}
},
{
"attributes": {
"OBJECTID": 1609,
"EASTING": 479156.0,
"NORTHING": 9864462.0,
"ANOMALY_CATEGORY": "Row Walking Survey",
"FUNCTIONAL_LOCATION": "HDL/CPA /OIL/TRANS/8_CPA_TO_SNP",
"ANOMALY_NAME": "3rd Party Activity",
"ANOMALY_CODE": "RWW-3PA",
"SAP_NOTIFICATION": null,
"ANOMALY_REFF_NUMBER": "RWW-3PA-7",
"ANOMALY_CLOSE": "No",
"ANOMALY_DATE_CREATED": 1678161600000,
"ANOMALY_CREATED_BY": "Rascal",
"ANOMALY_DESC": "Test drive",
"ANOMALY_RISK": "2 (Medium) - Non-Standard Condition",
"ANOMALY_STATUS": "Open",
"ANOMALY_COMMENT": "No comment aku",
"ACTION_ASSIGN_TO": "PO/OSF/INS/PIM",
"ACTION_COMMENT": null,
"KP": null,
"SURVEY_DATE": 1678161600000,
"STATUS_VALIDATED": "Validated",
"STATUS_REVIEW": null,
"REVIEWED_BY": null,
"GlobalID": "{AC962425-CF81-4A62-AC94-2A322E4C0579}"
},
"geometry": {
"x": 116.81264485400004,
"y": -1.2262399559999722
}
},
{
"attributes": {
"OBJECTID": 1610,
"EASTING": 479156.0,
"NORTHING": 9864462.0,
"ANOMALY_CATEGORY": "Row Walking Survey",
"FUNCTIONAL_LOCATION": "HDL/CPA /OIL/TRANS/8_CPA_TO_SNP",
"ANOMALY_NAME": "3rd Party Activity",
"ANOMALY_CODE": "RWW-3PA",
"SAP_NOTIFICATION": null,
"ANOMALY_REFF_NUMBER": "RWW-3PA-7",
"ANOMALY_CLOSE": "No",
"ANOMALY_DATE_CREATED": 1678161600000,
"ANOMALY_CREATED_BY": "Rascal",
"ANOMALY_DESC": "Test drive",
"ANOMALY_RISK": "2 (Medium) - Non-Standard Condition",
"ANOMALY_STATUS": "Open",
"ANOMALY_COMMENT": "No comment aku",
"ACTION_ASSIGN_TO": "PO/OSF/INS/PIM",
"ACTION_COMMENT": null,
"KP": null,
"SURVEY_DATE": 1678161600000,
"STATUS_VALIDATED": "Validated",
"STATUS_REVIEW": null,
"REVIEWED_BY": null,
"GlobalID": "{016D9D44-CA20-4EA5-8DEA-B526A4A3F538}"
},
"geometry": {
"x": 116.81264485400004,
"y": -1.2262399559999722
}
},
{
"attributes": {
"OBJECTID": 3208,
"EASTING": 479156.0,
"NORTHING": 9864462.0,
"ANOMALY_CATEGORY": "Row Walking Survey",
"FUNCTIONAL_LOCATION": "HDL/CPA /OIL/TRANS/8_CPA_TO_SNP",
"ANOMALY_NAME": "Corrosion Eviden",
"ANOMALY_CODE": "RWW-CE",
"SAP_NOTIFICATION": null,
"ANOMALY_REFF_NUMBER": "RWW-CE-8",
"ANOMALY_CLOSE": "No",
"ANOMALY_DATE_CREATED": 1678161600000,
"ANOMALY_CREATED_BY": "Rascal",
"ANOMALY_DESC": "Test drive",
"ANOMALY_RISK": "1 (High) - Immediate Action",
"ANOMALY_STATUS": "Open",
"ANOMALY_COMMENT": "No comment aku",
"ACTION_ASSIGN_TO": "PO/OSF/INS/PIM",
"ACTION_COMMENT": null,
"KP": null,
"SURVEY_DATE": 1678161600000,
"STATUS_VALIDATED": "Validated",
"STATUS_REVIEW": null,
"REVIEWED_BY": null,
"GlobalID": "{49D3D5C9-B644-4868-B522-F687E6968167}"
},
"geometry": {
"x": 116.81264485400004,
"y": -1.2262399559999722
}
},
{
"attributes": {
"OBJECTID": 3608,
"EASTING": 479156.0,
"NORTHING": 9864462.0,
"ANOMALY_CATEGORY": "Row Walking Survey",
"FUNCTIONAL_LOCATION": "HDL/CPA /OIL/TRANS/8_CPA_TO_SNP",
"ANOMALY_NAME": "Marker/Sign",
"ANOMALY_CODE": "RWW-SMS",
"SAP_NOTIFICATION": null,
"ANOMALY_REFF_NUMBER": "RWW-SMS-6",
"ANOMALY_CLOSE": "No",
"ANOMALY_DATE_CREATED": 1678161600000,
"ANOMALY_CREATED_BY": "Rascal",
"ANOMALY_DESC": "Test drive",
"ANOMALY_RISK": "3 (Low) - Monitoring/Observation",
"ANOMALY_STATUS": "Open",
"ANOMALY_COMMENT": "No comment aku",
"ACTION_ASSIGN_TO": "PO/OSF/INS/PIM",
"ACTION_COMMENT": null,
"KP": "kp 123",
"SURVEY_DATE": 1659326400000,
"STATUS_VALIDATED": "Validated",
"STATUS_REVIEW": null,
"REVIEWED_BY": null,
"GlobalID": "{E12BD9BE-FFDF-4D94-A39F-A4FECD8E7717}"
},
"geometry": {
"x": 116.81264485400004,
"y": -1.2262399559999722
}
}
],
"exceededTransferLimit": false
},
Distance__value_or_field_: {
"distance": radius,
"units": unit
},
f: "pjson"
};
geoprocessor.execute(gpUrl, params).then(drawResultData);
}
const drawResultData = function (result) {
const resultFeatures = result.results[0].value.features;
const viewshedGraphics = resultFeatures.map((feature) => {
feature.symbol = fillSymbol;
console.log(feature);
return feature;
});
graphicsLayer.addMany(viewshedGraphics);
webmap.add(graphicsLayer);
view.goTo({
target: viewshedGraphics,
tilt: 0
})
.catch((error) => {
if (error.name != "AbortError") {
console.error(error);
}
});
}
});
})