Skip to content

Instantly share code, notes, and snippets.

@andygup
andygup / esri_directions_input
Last active April 17, 2017 18:19
A pubnub block for creating directions using the Esri routing service
/*
This ArcGIS-based PubNub Block shows a pattern for running the routing service to find the best way to get from one location to another or to visit several locations.
Declare the Event Handler with the export syntax. The incoming message is called request.
The request object contains a starting coordinate and an ending coordinate:
Set up the test payload
{
"start": {
"lat": 37.783,
@andygup
andygup / esri_reverse_geocoding_input
Last active March 29, 2017 22:24
A pubnub block for converting lat/lon to an address
/*
This ArcGIS-based PubNub Block shows a pattern for converting a lat/lon coordinate to an address
Declare the Event Handler with the export syntax. The incoming message is called request.
Set up the test payload
{
"lat": -105.521,
"lon": 40.377
}
<!DOCTYPE html>
<html>
<head>
<!--
Finds Esri Geoenrichment data within a 1 mile radius of a map click event
-->
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
@andygup
andygup / esri_geoenrichment_input_proxy
Created March 22, 2017 23:25
Pubnub block for running an ArcGIS demographic analysis request via an ArcGIS Online hosted geoenrichment service.
/*
This ArcGIS-based pubnub block shows a pattern for running powerful demographic data searches.
Declare the Event Handler with the export syntax. The incoming message is called request.
The request object can either be a single point or a polygon. Here is an example, 'y' is Latitude
and 'x' is Longitude:
{
"x": -122.435,
"y": 37.785
@andygup
andygup / esri_geoenrichment_input
Last active March 20, 2017 15:54
Pubnub block for running an ArcGIS demographic analysis request
/*
This ArcGIS-based pubnub block shows a pattern for running powerful demographic data searches.
Declare the Event Handler with the export syntax. The incoming message is called request.
The request object can either be a single point or a polygon. Here is an example, 'y' is Latitude
and 'x' is Longitude:
{
"x": -122.435,
"y": 37.785
@andygup
andygup / GeoenrichmentRequest.html
Created March 14, 2017 16:35
Geoenrichment request
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>XHR</title>
</head>
<body>
<div id="result">Some result goes here</div>
<script>
var url = "https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/GeoEnrichment/enrich";
@andygup
andygup / CreateMapWidget
Created February 7, 2017 16:35
Create an ArcGIS JS API 4.x widget using a simple template
function createMapWidgets() {
var is2d = viewIs2D();
// Home
homeWidget = new Home({view: view});
view.ui.add(homeWidget, "top-left");
// Zoom
zoomWidget = new Zoom({view: view});
view.ui.add(zoomWidget, "top-left");
// Compass
compassWidget = new Compass({view: view});
@andygup
andygup / in-memory-feature-collection-js
Last active April 18, 2018 03:05
An ArcGIS JavaScript sample showing how to use an in-memory feature collection for creating a feature layer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>FeatureLayer</title>
<!-- ArcGIS JavaScript API - Required CSS -->
<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
"use strict";
/*
* Utility library for deleting all features in a feature layer.
* Use this to reset demo feature layers.
* WARNING: this will delete EVERYTHING!
*/
function CleanFeatureLayer(featureLayer, callback)
@andygup
andygup / appcache-features-edit.html
Created February 1, 2016 23:44
Full offline JS editing widget - (work in progress, NOT final)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0:, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">