Skip to content

Instantly share code, notes, and snippets.

@raykendo
raykendo / GetTimeStamp.js
Last active November 24, 2015 20:56
Dojo time stamp browser plugins
/**
* Gets a time stamp out of either localStorage, or a cookie session, if those are available.
* Use in conjunction with SetTimeStamp module.
* @module GetTimeStamp
* @param {string} id - string id you want to use to retrieve a time stamp from the browser
* @returns {Date} - Date of the last time stamp
*/
define(["dojo/cookie"], function (cookie) {
return {
load: function (id, require, callback) {
@nickpeihl
nickpeihl / index.html
Last active January 27, 2016 23:24
San Juan County Aerials in Mapbox-GL.js
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.5/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.5/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@raykendo
raykendo / georgeWashington.js
Last active November 17, 2015 16:16
George Washington - A user testing test
/**
* This script is a test to see whether the people who are supposed to be user testing your site are actually doing
* anything. It injects a piece of red text with content of George Washington somewhere in the document. It's designed
* to look for lowest hanging HTML dom nodes in the DOM tree (no children elements) that are visible (offsetParent is not null).
*/
(function () {
var nodes = Array.prototype.filter.call(document.querySelectorAll('div, p, span, blockquote, code, a, td'), function (node) {
return !(node.children && node.children.length) && node.offsetParent !== null;
});
if (nodes.length) {
@raykendo
raykendo / UTCToMyDateTime.js
Last active March 29, 2016 15:48
UTC to current time zone converter
/*
* Dojo AMD helper function to convert dates stored as UTC milliseconds from January 1, 1970 to a date/time format more fitting
* for current location.
* Reason: ArcGIS Server stores dates without times as midnight UTC. When those times are translated into real dates,
* the browser often corrects the date for time zone differences, moving the date back several hours in the U.S.
*/
/* globals define */
define(function () {
var oneDay = 24 * 60 * 60 * 1000;
/**
@raykendo
raykendo / BigQueryTask.js
Last active February 12, 2022 00:21
ArcGIS JSAPI Hack - Getting around the 1000 results limit for queries
/** globals define */
define([
"dojo/_base/declare",
"dojo/Deferred",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/request"
], function (
declare, Deferred, Query, QueryTask, esriRequest
) {
@raykendo
raykendo / customMeasurementDijit.js
Last active August 29, 2015 14:23
ArcGIS JSAPI: Measurement + Popup Combo
/*
* Custom Measurement Widget extension that connects to Popup dijit (esri/dijit/Popup),
* retrieves the selected feature, then passes the geometry to be measured by the Measurement Dijit.
*/
define("custom.Measurement",
[
"dojo/_base/declare",
"dojo/_base/lang",
"esri/dijit/Measurement",
"dojo/query",
@kaito834
kaito834 / urllib-request_basicAuth.py
Last active October 26, 2022 17:52
Python 3.x snippet code for Basic Authentication HTTP request by urllib.request
#!/usr/bin/env python
#
# I tested by Python 3.4.3 on Windows 8.1
# Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
import urllib.request
import getpass
# If you access to url below via Proxy,
# set environment variable 'http_proxy' before execute this.
@raykendo
raykendo / arcgis-jsapi-map-zoom-in-closer.js
Created May 29, 2015 21:08
ArcGIS JSAPI: Map with ESRI basemap zooming in closer than basemap allows.
require(["esri/Map"], function (Map) {
var map = new Map("mapdiv", {
basemap: "streets",
center: [-15.469, 36.428]
lods: [
//{
// level: 0,
// resolution: 156543.033928,
// scale: 591657527.591555
//},
@raykendo
raykendo / arcgis-jsapi-ondrawbegin.js
Last active August 29, 2015 14:21
ArcGIS-JSAPI: DrawingToolbar hack for onDrawBegin
/*
* Making up for a missing "draw-begin" or "draw-start" event for the ArcGIS JavaScript API Drawing toolbar
*
* Problem: While the drawing toolbar in the ArcGIS JavaScript API has a "draw-end" and a "draw-complete"
* event, it doesn't have a "draw-start" or "draw-begin" event.
*
* Solution: Use a dojo/on pausable event that is only unpaused after the draw-end event.
*/
require(["esri/map", "dojo/on", "esri/toolbars/draw"], function (Map, dojoOn, Draw) {
var map = new Map("mapdiv", {});
@raykendo
raykendo / ArcGIS-JSAPI-MapClickByQueryHack.md
Last active July 6, 2018 20:29
ArcGIS-JSAPI: Clicking on a webmap without clicking on a webmap

Clicking on a map without clicking on a map

An ArcGIS JavaScript API hack

Purpose: I have a map application with a list of results from a query. When I click on one of the items in the result list, I wanted the map to zoom to the associated feature, and trigger a click that shows the result in a popup.

Library: ArcGIS JavaScript API

Version: tested on versions 3.9-3.13.