Skip to content

Instantly share code, notes, and snippets.

@nommuna2
nommuna2 / Sample.js
Last active December 19, 2024 18:49
(ArcGIS API for JavaScript) Sample of using chart.js with the Esri 4.7 API
//Please go to the following jsbin for a working sample: https://jsbin.com/nejolahicu/1/edit?html,js,output
//Depending on server load, it may take awhile for the feature layer to load and be displayed on the map.
require([
"esri/Map",
"esri/views/MapView",
"esri/PopupTemplate",
"esri/layers/FeatureLayer",
"esri/widgets/Popup",
"esri/tasks/support/Query",
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.js",
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:27
(ArcGIS API for JavaScript) Sample of getting user items and accessing secured layers without user authentication.
require(["esri/map",
"esri/arcgis/Portal",
"esri/urlUtils",
"esri/request",
"esri/config",
"dojo/domReady!"
], function (Map, arcgisPortal,urlUtils, Request, Config) {
//Push the server to the cors array to avoid CORS related errors.
Config.defaults.io.corsEnabledServers.push("FQDN of server");
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:30
(ArcGIS API for JavaScript) Add Breaks renderer example JS 3.23
require(["esri/map",
"esri/layers/FeatureLayer",
"esri/renderers/ClassBreaksRenderer",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/query",
"dojo/domReady!"
], function (Map, FeatureLayer,ClassBreaksRenderer,SimpleMarkerSymbol,Color,SimpleLineSymbol,Query) {
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:32
(ArcGIS API for JavaScript) Sample for orderByFields using classBreaksRenderer
require(["esri/map",
"esri/layers/FeatureLayer",
"esri/renderers/ClassBreaksRenderer",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/query",
"dojo/domReady!"
], function (Map, FeatureLayer, ClassBreaksRenderer, SimpleMarkerSymbol, Color, SimpleLineSymbol, Query) {
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:35
(ArcGIS API for JavaScript) Sample of how to add an arrow to the end of a line in the Legend using js
//Make sure the layer is loaded, the query all path elements and add the attribute to the specific path you want
fl.on("update-end", (e) => {
document.querySelectorAll("* path").forEach((e,i) => {
if(i === 3){
e.setAttribute("marker-start", "url(#marker_map_0_0_0_start)");
e.setAttribute("marker-end", "url(#marker_map_0_0_0_end)");
}
console.log(e);
});
});
@nommuna2
nommuna2 / Sample.css
Created April 11, 2018 23:35
Sample of how to add an arrow to the end of a line in the Legend using css
#legendDiv_graphicsLayer1_0 > table.esriLegendLayer > tbody > tr > td:nth-child(1) > div > svg > path {
marker-start: url(#marker_map_0_0_0_start);
marker-end: url(#marker_map_0_0_0_end);
}
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:49
(ArcGIS API for JavaScript) Sample of selecting the nearest street using buffer in 3.x
require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/renderers/SimpleRenderer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/Color",
"esri/tasks/query",
"esri/geometry/geometryEngine",
"esri/graphic",
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:54
(ArcGIS API for JavaScript) Sample of passing a feature set to a GPService (Event driven)
require(["esri/map",
"esri/layers/FeatureLayer",
"esri/tasks/QueryTask",
"esri/tasks/query",
"esri/tasks/Geoprocessor",
"dojo/domReady!"
], function (Map, FeatureLayer, QueryTask, Query, Geoprocessor) {
//Initializing the map constructor
var map = new Map("map", {
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:56
(ArcGIS API for JavaScript) Extrusion 3D and Unique Renderer
require([
"esri/Map",
"esri/views/SceneView",
"esri/layers/FeatureLayer",
"esri/symbols/PolygonSymbol3D",
"esri/symbols/ExtrudeSymbol3DLayer",
"esri/renderers/SimpleRenderer",
"esri/renderers/UniqueValueRenderer",
"dojo/domReady!"
],
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:56
(ArcGIS API for JavaScript) Geometry Engine (cut and buffer)
//This example is using the geometry engine to buffer around a line and use the cut method to get two half's
require([
"esri/Map",
"esri/views/MapView",
"esri/geometry/Polyline",
"esri/geometry/geometryEngine",
"esri/symbols/SimpleLineSymbol",
"esri/Graphic",
"esri/symbols/SimpleFillSymbol",
"dojo/domReady!"