Skip to content

Instantly share code, notes, and snippets.

@andygup
andygup / timer-worker.js
Last active July 30, 2018 16:21
Simple timer that runs on web worker thread
let time;
onmessage = function(msg){
let value = msg.data;
const interval = value[1];
if(value[0] == "start"){
console.log("Starting timer...");
time = setInterval(function(){
@andygup
andygup / CSVReader.js
Created February 9, 2018 02:07
Example csv parser using FileReader
this._loadFromFile = function(file,store,callback){
if (window.File && window.FileReader && window.FileList && window.Blob)
{
// Great success! All the File APIs are supported.
var reader = new FileReader();
reader.onload = function(evt)
{
var csvContent = evt.target.result;
var tiles = csvContent.split("\r\n");
var tileCount = 0;
@andygup
andygup / Clock.js
Created January 30, 2018 00:05
A javascript clock
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.Clock = factory();
}
}(this, function () {
@andygup
andygup / 2D-build.profile.js
Created November 14, 2017 00:16
Bare bones 2D build of the ArcGIS API for JavaScript 4.5
/**
* Based on the dojo-boilerplate
* https://github.com/csnover/dojo-boilerplate
* and https://github.com/tomwayson/esri-slurp-example
*
* Please refer to the Dojo Build tutorial for more details
* http://dojotoolkit.org/documentation/tutorials/1.10/build/
* Look to `util/build/buildControlDefault.js` for more information on available options and their default values.
*/
<!DOCTYPE html>
<html manifest="https://rawgit.com/andygup/a1dd6f3228d44d86c466051420ba9166/raw/50f2288334122e3fdf3c176c96fec7f21ee9450a/appcache-test.appcache">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>FeatureLayer - 4.5</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.5/esri/css/main.css">
<script src="https://js.arcgis.com/4.5/"></script>
CACHE MANIFEST
# Time: Tue Oct 31 2017 09:22:04 GMT-0700 (MST)
CACHE:
#JSAPI_files
https://js.arcgis.com/4.5/esri/css/main.css
https://js.arcgis.com/4.5/init.js
https://js.arcgis.com/4.5/dojo/nls/dojo_en-us.js
https://js.arcgis.com/4.5/esri/views/MapView.js
@andygup
andygup / pubnub_esri_geoenrichment.js
Created August 16, 2017 00:05
Demographics analysis with self-renewing ArcGIS token
/*
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 / create_access_token.js
Last active August 10, 2017 00:40
Create an ArcGIS Online access_token programmatically
// Uses the following test payload
/*
{
"lon": -122.435,
"lat": 37.785
}
*/
export default (request) => {
const xhr = require('xhr');
const url = "https://www.arcgis.com/sharing/rest/oauth2/token/";
@andygup
andygup / js4-webmap-click.html
Last active December 12, 2022 07:13
Click on ArcGIS JS API 4.x webmap and draw a marker graphic if a feature exists
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Dock Positions with Popup - 4.3</title>
<style>
html,
body,
@andygup
andygup / 3DEarthquakes.html
Last active May 15, 2017 21:42
3D Earthquake Demo - JSAPI 4
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>CSVLayer - 4.3</title>
<style>
html,
body,