Skip to content

Instantly share code, notes, and snippets.

@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: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.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: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: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 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:19
(ArcGIS API for JavaScript) Sample of creating a form in a popup and using applyEdits operation to make edits to the feature layer.
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/widgets/Popup",
"esri/Graphic",
"dojo/domReady!"
],
function (Map, MapView, FeatureLayer, Popup, Graphic) {
@nommuna2
nommuna2 / index.html
Last active January 8, 2020 17:55
(ArcGIS API for JavaScript) Sample of using chart.js with the Esri 4.7 API (Typescript version)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>ArcGIS JSAPI 4.6 TypeScript Demo</title>
<style>
html,
body,
#viewDiv {
@nommuna2
nommuna2 / Sample.py
Last active April 26, 2019 21:16
(ArcGIS API for Python) Sample of turning a feature set to a feature collection using python api
import arcgis
from arcgis.gis import GIS
try:
gis = GIS(None,"USERNAME", "PASSWORD", verify_cert=False)
featureLayer = gis.content.get('ID')
# A Query operation returns a FeatureSet (https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html?highlight=query#featureset)
featureSet = featureLayer.layers[0].query(where="1=1", out_fields="*")
#Use the featureSet to make a featureCollection
featureCollection = arcgis.features.FeatureCollection.from_featureset(featureSet)
@nommuna2
nommuna2 / Sample.js
Last active April 26, 2019 21:15
(ArcGIS API for JavaScript) Sample of rendering polylines from a csv
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/CSVLayer",
"esri/config",
"esri/geometry/Polyline",
"esri/Graphic",
"esri/layers/GraphicsLayer",
"esri/layers/FeatureLayer",
"esri/layers/support/Field",