Skip to content

Instantly share code, notes, and snippets.

@tristen
Last active January 25, 2016 13:57
Show Gist options
  • Select an option

  • Save tristen/8cb712f7cec408c6cbfe to your computer and use it in GitHub Desktop.

Select an option

Save tristen/8cb712f7cec408c6cbfe to your computer and use it in GitHub Desktop.
!function t(e,r,n){function i(u,s){if(!r[u]){if(!e[u]){var a="function"==typeof require&&require;if(!s&&a)return a(u,!0);if(o)return o(u,!0);var h=new Error("Cannot find module '"+u+"'");throw h.code="MODULE_NOT_FOUND",h}var c=r[u]={exports:{}};e[u][0].call(c.exports,function(t){var r=e[u][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[u].exports}for(var o="function"==typeof require&&require,u=0;u<n.length;u++)i(n[u]);return i}({1:[function(t,e,r){"use strict";function n(t){_=_.slice(0,l+1);var e=t(_[l]);_.push(e),l++,o()}function i(){c.addSource("geojson",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),c.addLayer({id:"polygon-query-fill",type:"fill",source:"geojson",paint:{"fill-color":"#027dbd","fill-opacity":.1}}),c.addLayer({id:"polygon-query-line",type:"line",source:"geojson",paint:{"line-color":"#027dbd","line-width":3}});var t=c.getCanvas().offsetWidth,e=c.getCanvas().offsetHeight,r=document.getElementById("canvas");r.setAttribute("width",t),r.setAttribute("height",e);var n=new a(r);n.disable();var i=c.getContainer().querySelector(".mapboxgl-ctrl-top-left"),o=document.createElement("div");o.className="mapboxgl-ctrl draw-ctrl round fill-darken2 dark";var s=document.createElement("button");s.className="icon pencil dark round draw-ctrl",s.addEventListener("click",function(t){s.classList.contains("active")?(s.classList.remove("active"),r.classList.add("hidden"),n.disable()):(s.classList.add("active"),r.classList.remove("hidden"),n.enable())}),o.appendChild(s),i.appendChild(o),n.on("result",function(t){var e={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}};t.result.forEach(function(t){var r=c.unproject(t);e.geometry.coordinates[0].push([r.lng,r.lat])}),e.geometry.coordinates[0].push(e.geometry.coordinates[0][0]),u(h(e,.01,!0)),n.clear()})}function o(){var t=[];_[l].forEach(function(e){t.push(e.get("feature"))}),f.disabled=0!=l?"":"disabled",p.disabled=l!==_.length-1?"":"disabled",c.getSource("geojson").setData({type:"FeatureCollection",features:t})}function u(t){n(function(e){return e.push(s.Map({feature:t,id:+new Date}))})}mapboxgl.accessToken="pk.eyJ1IjoiY293b3JraW5nZGVtbyIsImEiOiJjaWh6MTNpb2owNDNkdGZraGhzOHB1NjZqIn0.H2wW34WF8EWDVcpq1fN7dA";var s=t("immutable"),a=t("./pencil"),h=t("turf-simplify"),c=new mapboxgl.Map({container:"map",style:"mapbox://styles/coworkingdemo/cii0zwz8y0112npm4xa9epcm5?3",center:[-20,29],zoom:2});c.addControl(new mapboxgl.Navigation({position:"top-left"}));var f=document.getElementById("undo"),p=document.getElementById("redo"),_=[s.List([])],l=0;f.addEventListener("click",function(){l>0&&l--,o()}),p.addEventListener("click",function(){l<_.length&&l++,o()}),c.on("load",i)},{"./pencil":8,immutable:3,"turf-simplify":6}],2:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"number"==typeof t}function u(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!o(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,o,a,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),r.apply(this,o)}else if(u(r))for(o=Array.prototype.slice.call(arguments,1),h=r.slice(),n=h.length,a=0;n>a;a++)h[a].apply(this,o);return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?u(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,u(this._events[t])&&!this._events[t].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,o,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(u(r)){for(s=o;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],3:[function(t,e,r){!function(t,n){"object"==typeof r&&"undefined"!=typeof e?e.exports=n():"function"==typeof define&&define.amd?define(n):t.Immutable=n()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return o(t)?t:M(t)}function r(t){return u(t)?t:O(t)}function n(t){return s(t)?t:k(t)}function i(t){return o(t)&&!a(t)?t:A(t)}function o(t){return!(!t||!t[ar])}function u(t){return!(!t||!t[hr])}function s(t){return!(!t||!t[cr])}function a(t){return u(t)||s(t)}function h(t){return!(!t||!t[fr])}function c(t){return t.value=!1,t}function f(t){t&&(t.value=!0)}function p(){}function _(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=new Array(r),i=0;r>i;i++)n[i]=t[i+e];return n}function l(t){return void 0===t.size&&(t.size=t.__iterate(y)),t.size}function v(t,e){if("number"!=typeof e){var r=e>>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return 0>e?l(t)+e:e}function y(){return!0}function d(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function m(t,e){return w(t,e,0)}function g(t,e){return w(t,e,e)}function w(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function S(t){this.next=t}function b(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function x(){return{value:void 0,done:!0}}function z(t){return!!q(t)}function I(t){return t&&"function"==typeof t.next}function E(t){var e=q(t);return e&&e.call(t)}function q(t){var e=t&&(br&&t[br]||t[xr]);return"function"==typeof e?e:void 0}function D(t){return t&&"number"==typeof t.length}function M(t){return null===t||void 0===t?K():o(t)?t.toSeq():W(t)}function O(t){return null===t||void 0===t?K().toKeyedSeq():o(t)?u(t)?t.toSeq():t.fromEntrySeq():T(t)}function k(t){return null===t||void 0===t?K():o(t)?u(t)?t.entrySeq():t.toIndexedSeq():P(t)}function A(t){return(null===t||void 0===t?K():o(t)?u(t)?t.entrySeq():t:P(t)).toSetSeq()}function L(t){this._array=t,this.size=t.length}function j(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function U(t){this._iterable=t,this.size=t.length||t.size}function R(t){this._iterator=t,this._iteratorCache=[]}function C(t){return!(!t||!t[Ir])}function K(){return Er||(Er=new L([]))}function T(t){var e=Array.isArray(t)?new L(t).fromEntrySeq():I(t)?new R(t).fromEntrySeq():z(t)?new U(t).fromEntrySeq():"object"==typeof t?new j(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function P(t){var e=B(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function W(t){var e=B(t)||"object"==typeof t&&new j(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function B(t){return D(t)?new L(t):I(t)?new R(t):z(t)?new U(t):void 0}function N(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var s=i[r?o-u:u];if(e(s[1],n?s[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function J(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new S(function(){var t=i[r?o-u:u];return u++>o?x():b(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function H(t,e){return e?F(e,t,"",{"":t}):V(t)}function F(t,e,r,n){return Array.isArray(e)?t.call(n,r,k(e).map(function(r,n){return F(t,r,n,e)})):Y(e)?t.call(n,r,O(e).map(function(r,n){return F(t,r,n,e)})):e}function V(t){return Array.isArray(t)?k(t).map(V).toList():Y(t)?O(t).map(V).toMap():t}function Y(t){return t&&(t.constructor===Object||void 0===t.constructor)}function G(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function X(t,e){if(t===e)return!0;if(!o(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||u(t)!==u(e)||s(t)!==s(e)||h(t)!==h(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!a(t);if(h(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&G(i[1],t)&&(r||G(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var c=t;t=e,e=c}var f=!0,p=e.__iterate(function(e,n){return(r?t.has(e):i?G(e,t.get(n,yr)):G(t.get(n,yr),e))?void 0:(f=!1,!1)});return f&&t.size===p}function Z(t,e){if(!(this instanceof Z))return new Z(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(qr)return qr;qr=this}}function $(t,e){if(!t)throw new Error(e)}function Q(t,e,r){if(!(this instanceof Q))return new Q(t,e,r);if($(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(Dr)return Dr;Dr=this}}function tt(){throw TypeError("Abstract")}function et(){}function rt(){}function nt(){}function it(t){return t>>>1&1073741824|3221225471&t}function ot(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return it(r)}if("string"===e)return t.length>Rr?ut(t):st(t);if("function"==typeof t.hashCode)return t.hashCode();if("object"===e)return at(t);if("function"==typeof t.toString)return st(t.toString());throw new Error("Value type "+e+" cannot be hashed.")}function ut(t){var e=Tr[t];return void 0===e&&(e=st(t),Kr===Cr&&(Kr=0,Tr={}),Kr++,Tr[t]=e),e}function st(t){for(var e=0,r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return it(e)}function at(t){var e;if(Lr&&(e=Mr.get(t),void 0!==e))return e;if(e=t[Ur],void 0!==e)return e;if(!Ar){if(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ur],void 0!==e)return e;if(e=ht(t),void 0!==e)return e}if(e=++jr,1073741824&jr&&(jr=0),Lr)Mr.set(t,e);else{if(void 0!==kr&&kr(t)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(Ar)Object.defineProperty(t,Ur,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ur]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ur]=e}}return e}function ht(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ct(t){$(t!==1/0,"Cannot perform this action with an infinite size.")}function ft(t){return null===t||void 0===t?bt():pt(t)&&!h(t)?t:bt().withMutations(function(e){var n=r(t);ct(n.size),n.forEach(function(t,r){return e.set(r,t)})})}function pt(t){return!(!t||!t[Pr])}function _t(t,e){this.ownerID=t,this.entries=e}function lt(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function vt(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function yt(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function dt(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function mt(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&wt(t._root)}function gt(t,e){return b(t,e[0],e[1])}function wt(t,e){return{node:t,index:0,__prev:e}}function St(t,e,r,n){var i=Object.create(Wr);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function bt(){return Br||(Br=St(0))}function xt(t,e,r){var n,i;if(t._root){var o=c(dr),u=c(mr);if(n=zt(t._root,t.__ownerID,0,void 0,e,r,o,u),!u.value)return t;i=t.size+(o.value?r===yr?-1:1:0)}else{if(r===yr)return t;i=1,n=new _t(t.__ownerID,[[e,r]])}return t.__ownerID?(t.size=i,t._root=n,t.__hash=void 0,t.__altered=!0,t):n?St(i,n):bt()}function zt(t,e,r,n,i,o,u,s){return t?t.update(e,r,n,i,o,u,s):o===yr?t:(f(s),f(u),new dt(e,n,[i,o]))}function It(t){return t.constructor===dt||t.constructor===yt}function Et(t,e,r,n,i){if(t.keyHash===n)return new yt(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&vr,s=(0===r?n:n>>>r)&vr,a=u===s?[Et(t,e,r+_r,n,i)]:(o=new dt(e,n,i),s>u?[t,o]:[o,t]);return new lt(e,1<<u|1<<s,a)}function qt(t,e,r,n){t||(t=new p);for(var i=new dt(t,ot(r),[r,n]),o=0;o<e.length;o++){var u=e[o];i=i.update(t,0,void 0,u[0],u[1])}return i}function Dt(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,h=e.length;h>s;s++,a<<=1){var c=e[s];void 0!==c&&s!==n&&(i|=a,u[o++]=c)}return new lt(t,i,u)}function Mt(t,e,r,n,i){for(var o=0,u=new Array(lr),s=0;0!==r;s++,r>>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new vt(t,o+1,u)}function Ot(t,e,n){for(var i=[],u=0;u<n.length;u++){var s=n[u],a=r(s);o(s)||(a=a.map(function(t){return H(t)})),i.push(a)}return Lt(t,e,i)}function kt(t,e,r){return t&&t.mergeDeep&&o(e)?t.mergeDeep(e):G(t,e)?t:e}function At(t){return function(e,r,n){if(e&&e.mergeDeepWith&&o(r))return e.mergeDeepWith(t,r);var i=t(e,r,n);return G(e,i)?e:i}}function Lt(t,e,r){return r=r.filter(function(t){return 0!==t.size}),0===r.length?t:0!==t.size||t.__ownerID||1!==r.length?t.withMutations(function(t){for(var n=e?function(r,n){t.update(n,yr,function(t){return t===yr?r:e(t,r,n)})}:function(e,r){t.set(r,e)},i=0;i<r.length;i++)r[i].forEach(n)}):t.constructor(r[0])}function jt(t,e,r,n){var i=t===yr,o=e.next();if(o.done){var u=i?r:t,s=n(u);return s===u?t:s}$(i||t&&t.set,"invalid keyPath");var a=o.value,h=i?yr:t.get(a,yr),c=jt(h,e,r,n);return c===h?t:c===yr?t.remove(a):(i?bt():t).set(a,c)}function Ut(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function Rt(t,e,r,n){var i=n?t:_(t);return i[e]=r,i}function Ct(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=new Array(i),u=0,s=0;i>s;s++)s===e?(o[s]=r,u=-1):o[s]=t[s+u];return o}function Kt(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function Tt(t){var e=Jt();if(null===t||void 0===t)return e;if(Pt(t))return t;var r=n(t),i=r.size;return 0===i?e:(ct(i),i>0&&lr>i?Nt(0,i,_r,null,new Wt(r.toArray())):e.withMutations(function(t){t.setSize(i),r.forEach(function(e,r){return t.set(r,e)})}))}function Pt(t){return!(!t||!t[Fr])}function Wt(t,e){this.array=t,this.ownerID=e}function Bt(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===s?a&&a.array:t&&t.array,i=r>o?0:o-r,h=u-r;return h>lr&&(h=lr),function(){if(i===h)return Gr;var t=e?--h:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,h=i>o?0:o-i>>n,c=(u-i>>n)+1;return c>lr&&(c=lr),function(){for(;;){if(s){var t=s();if(t!==Gr)return t;s=null}if(h===c)return Gr;var o=e?--c:h++;s=r(a&&a[o],n-_r,i+(o<<n))}}}var o=t._origin,u=t._capacity,s=Zt(u),a=t._tail;return r(t._root,t._level,0)}function Nt(t,e,r,n,i,o,u){var s=Object.create(Vr);return s.size=e-t,s._origin=t,s._capacity=e,s._level=r,s._root=n,s._tail=i,s.__ownerID=o,s.__hash=u,s.__altered=!1,s}function Jt(){return Yr||(Yr=Nt(0,0,_r))}function Ht(t,e,r){if(e=v(t,e),e!==e)return t;if(e>=t.size||0>e)return t.withMutations(function(t){0>e?Gt(t,e).set(0,r):Gt(t,0,e+1).set(e,r)});e+=t._origin;var n=t._tail,i=t._root,o=c(mr);return e>=Zt(t._capacity)?n=Ft(n,t.__ownerID,0,e,r,o):i=Ft(i,t.__ownerID,t._level,e,r,o),o.value?t.__ownerID?(t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t):Nt(t._origin,t._capacity,t._level,i,n):t}function Ft(t,e,r,n,i,o){var u=n>>>r&vr,s=t&&u<t.array.length;if(!s&&void 0===i)return t;var a;if(r>0){var h=t&&t.array[u],c=Ft(h,e,r-_r,n,i,o);return c===h?t:(a=Vt(t,e),a.array[u]=c,a)}return s&&t.array[u]===i?t:(f(o),a=Vt(t,e),void 0===i&&u===a.array.length-1?a.array.pop():a.array[u]=i,a)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Wt(t?t.array.slice():[],e)}function Yt(t,e){if(e>=Zt(t._capacity))return t._tail;if(e<1<<t._level+_r){for(var r=t._root,n=t._level;r&&n>0;)r=r.array[e>>>n&vr],n-=_r;return r}}function Gt(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var n=t.__ownerID||new p,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:0>r?o+r:i+r;if(u===i&&s===o)return t;if(u>=s)return t.clear();for(var a=t._level,h=t._root,c=0;0>u+c;)h=new Wt(h&&h.array.length?[void 0,h]:[],n),a+=_r,c+=1<<a;c&&(u+=c,i+=c,s+=c,o+=c);for(var f=Zt(o),_=Zt(s);_>=1<<a+_r;)h=new Wt(h&&h.array.length?[h]:[],n),a+=_r;var l=t._tail,v=f>_?Yt(t,s-1):_>f?new Wt([],n):l;if(l&&_>f&&o>u&&l.array.length){h=Vt(h,n);for(var y=h,d=a;d>_r;d-=_r){var m=f>>>d&vr;y=y.array[m]=Vt(y.array[m],n)}y.array[f>>>_r&vr]=l}if(o>s&&(v=v&&v.removeAfter(n,0,s)),u>=_)u-=_,s-=_,a=_r,h=null,v=v&&v.removeBefore(n,0,u);else if(u>i||f>_){for(c=0;h;){var g=u>>>a&vr;if(g!==_>>>a&vr)break;g&&(c+=(1<<a)*g),a-=_r,h=h.array[g]}h&&u>i&&(h=h.removeBefore(n,a,u-c)),h&&f>_&&(h=h.removeAfter(n,a,_-c)),c&&(u-=c,s-=c)}return t.__ownerID?(t.size=s-u,t._origin=u,t._capacity=s,t._level=a,t._root=h,t._tail=v,t.__hash=void 0,t.__altered=!0,t):Nt(u,s,a,h,v)}function Xt(t,e,r){for(var i=[],u=0,s=0;s<r.length;s++){var a=r[s],h=n(a);h.size>u&&(u=h.size),o(a)||(h=h.map(function(t){return H(t)})),i.push(h)}return u>t.size&&(t=t.setSize(u)),Lt(t,e,i)}function Zt(t){return lr>t?0:t-1>>>_r<<_r}function $t(t){return null===t||void 0===t?ee():Qt(t)?t:ee().withMutations(function(e){var n=r(t);ct(n.size),n.forEach(function(t,r){return e.set(r,t)})})}function Qt(t){return pt(t)&&h(t)}function te(t,e,r,n){var i=Object.create($t.prototype);return i.size=t?t.size:0,i._map=t,i._list=e,i.__ownerID=r,i.__hash=n,i}function ee(){return Xr||(Xr=te(bt(),Jt()))}function re(t,e,r){var n,i,o=t._map,u=t._list,s=o.get(e),a=void 0!==s;if(r===yr){if(!a)return t;u.size>=lr&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):te(n,i)}function ne(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ie(t){this._iter=t,this.size=t.size}function oe(t){this._iter=t,this.size=t.size}function ue(t){this._iter=t,this.size=t.size}function se(t){var e=De(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Me,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Sr){var n=t.__iterator(e,r);return new S(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===wr?gr:wr,r)},e}function ae(t,e,r){var n=De(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,yr);return o===yr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Sr,i);return new S(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return b(n,s,e.call(r,u[1],s,t),i)})},n}function he(t,e){var r=De(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=se(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=Me,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function ce(t,e,r,n){var i=De(t);return n&&(i.has=function(n){var i=t.get(n,yr);return i!==yr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,yr);return o!==yr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){return e.call(r,t,o,a)?(s++,i(t,n?o:s-1,u)):void 0},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Sr,o),s=0;return new S(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,h=a[0],c=a[1];if(e.call(r,c,h,t))return b(i,n?h:s++,c,o)}})},i}function fe(t,e,r){var n=ft().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function pe(t,e,r){var n=u(t),i=(h(t)?$t():ft()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=qe(t);return i.map(function(e){return ze(t,o(e))})}function _e(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),d(e,r,i))return t;var o=m(e,i),u=g(r,i);if(o!==o||u!==u)return _e(t.toSeq().cacheResult(),e,r,n);var s,a=u-o;a===a&&(s=0>a?0:a);var h=De(t);return h.size=0===s?s:t.size&&s||void 0,!n&&C(t)&&s>=0&&(h.get=function(e,r){return e=v(this,e),e>=0&&s>e?t.get(e+o,r):r}),h.__iterateUncached=function(e,r){var i=this;if(0===s)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,a=!0,h=0;return t.__iterate(function(t,r){return a&&(a=u++<o)?void 0:(h++,e(t,n?r:h-1,i)!==!1&&h!==s)}),h},h.__iteratorUncached=function(e,r){if(0!==s&&r)return this.cacheResult().__iterator(e,r);var i=0!==s&&t.__iterator(e,r),u=0,a=0;return new S(function(){for(;u++<o;)i.next();if(++a>s)return x();var t=i.next();return n||e===wr?t:e===gr?b(e,a-1,void 0,t):b(e,a-1,t.value[1],t)})},h}function le(t,e,r){var n=De(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Sr,i),s=!0;return new S(function(){if(!s)return x();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],h=i[1];return e.call(r,h,a,o)?n===Sr?t:b(n,a,h,t):(s=!1,x())})},n}function ve(t,e,r,n){var i=De(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,h){return s&&(s=e.call(r,t,o,h))?void 0:(a++,i(t,n?o:a-1,u))}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Sr,o),a=!0,h=0;return new S(function(){var t,o,c;do{if(t=s.next(),t.done)return n||i===wr?t:i===gr?b(i,h++,void 0,t):b(i,h++,t.value[1],t);var f=t.value;o=f[0],c=f[1],a&&(a=e.call(r,c,o,u))}while(a);return i===Sr?t:b(i,o,c,t)})},i}function ye(t,e){var n=u(t),i=[t].concat(e).map(function(t){return o(t)?n&&(t=r(t)):t=n?T(t):P(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===i.length)return t;if(1===i.length){var a=i[0];if(a===t||n&&u(a)||s(t)&&s(a))return a}var h=new L(i);return n?h=h.toKeyedSeq():s(t)||(h=h.toSetSeq()),h=h.flatten(!0),h.size=i.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),h}function de(t,e,r){var n=De(t);return n.__iterateUncached=function(n,i){function u(t,h){var c=this;t.__iterate(function(t,i){return(!e||e>h)&&o(t)?u(t,h+1):n(t,r?i:s++,c)===!1&&(a=!0),!a},i)}var s=0,a=!1;return u(t,0),s},n.__iteratorUncached=function(n,i){var u=t.__iterator(n,i),s=[],a=0;return new S(function(){for(;u;){var t=u.next();if(t.done===!1){var h=t.value;if(n===Sr&&(h=h[1]),e&&!(s.length<e)||!o(h))return r?t:b(n,a++,h,t);s.push(u),u=h.__iterator(n,i)}else u=s.pop()}return x()})},n}function me(t,e,r){var n=qe(t);return t.toSeq().map(function(i,o){return n(e.call(r,i,o,t))}).flatten(!0)}function ge(t,e){var r=De(t);return r.size=t.size&&2*t.size-1,r.__iterateUncached=function(r,n){var i=this,o=0;return t.__iterate(function(t,n){return(!o||r(e,o++,i)!==!1)&&r(t,o++,i)!==!1},n),o},r.__iteratorUncached=function(r,n){var i,o=t.__iterator(wr,n),u=0;return new S(function(){return(!i||u%2)&&(i=o.next(),i.done)?i:u%2?b(r,u++,e):b(r,u++,i.value,i)})},r}function we(t,e,r){e||(e=Oe);var n=u(t),i=0,o=t.toSeq().map(function(e,n){return[n,e,i++,r?r(e,n,t):e]}).toArray();return o.sort(function(t,r){return e(t[3],r[3])||t[2]-r[2]}).forEach(n?function(t,e){o[e].length=2}:function(t,e){o[e]=t[1]}),n?O(o):s(t)?k(o):A(o)}function Se(t,e,r){if(e||(e=Oe),r){var n=t.toSeq().map(function(e,n){return[e,r(e,n,t)]}).reduce(function(t,r){return be(e,t[1],r[1])?r:t});return n&&n[0]}return t.reduce(function(t,r){return be(e,t,r)?r:t})}function be(t,e,r){var n=t(r,e);return 0===n&&r!==e&&(void 0===r||null===r||r!==r)||n>0}function xe(t,r,n){var i=De(t);return i.size=new L(n).map(function(t){return t.size}).min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(wr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},i.__iteratorUncached=function(t,i){var o=n.map(function(t){return t=e(t),E(i?t.reverse():t)}),u=0,s=!1;return new S(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=e.some(function(t){return t.done})),s?x():b(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function ze(t,e){return C(t)?e:t.constructor(e)}function Ie(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Ee(t){return ct(t.size),l(t)}function qe(t){return u(t)?r:s(t)?n:i}function De(t){return Object.create((u(t)?O:s(t)?k:A).prototype)}function Me(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):M.prototype.cacheResult.call(this)}function Oe(t,e){return t>e?1:e>t?-1:0}function ke(t){var r=E(t);if(!r){if(!D(t))throw new TypeError("Expected iterable or array-like: "+t);r=E(e(t))}return r}function Ae(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);Ue(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=ft(o)},i=n.prototype=Object.create(Zr);return i.constructor=n,n}function Le(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function je(t){return t._name||t.constructor.name||"Record"}function Ue(t,e){try{e.forEach(Re.bind(void 0,t))}catch(r){}}function Re(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){$(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function Ce(t){return null===t||void 0===t?We():Ke(t)&&!h(t)?t:We().withMutations(function(e){var r=i(t);ct(r.size),r.forEach(function(t){return e.add(t)})})}function Ke(t){return!(!t||!t[$r])}function Te(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Pe(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function We(){return tn||(tn=Pe(bt()))}function Be(t){return null===t||void 0===t?He():Ne(t)?t:He().withMutations(function(e){var r=i(t);ct(r.size),r.forEach(function(t){return e.add(t)})})}function Ne(t){return Ke(t)&&h(t)}function Je(t,e){var r=Object.create(en);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function He(){return rn||(rn=Je(ee()))}function Fe(t){return null===t||void 0===t?Ge():Ve(t)?t:Ge().unshiftAll(t)}function Ve(t){return!(!t||!t[nn])}function Ye(t,e,r,n){var i=Object.create(on);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Ge(){return un||(un=Ye(0))}function Xe(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ze(t,e){return e}function $e(t,e){return[e,t]}function Qe(t){return function(){return!t.apply(this,arguments)}}function tr(t){return function(){return-t.apply(this,arguments)}}function er(t){return"string"==typeof t?JSON.stringify(t):t}function rr(){return _(arguments)}function nr(t,e){return e>t?1:t>e?-1:0}function ir(t){if(t.size===1/0)return 0;var e=h(t),r=u(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+ur(ot(t),ot(e))|0}:function(t,e){n=n+ur(ot(t),ot(e))|0}:e?function(t){n=31*n+ot(t)|0}:function(t){n=n+ot(t)|0});return or(i,n)}function or(t,e){return e=Or(e,3432918353),e=Or(e<<15|e>>>-15,461845907),e=Or(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Or(e^e>>>16,2246822507),e=Or(e^e>>>13,3266489909),e=it(e^e>>>16)}function ur(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var sr=Array.prototype.slice;t(r,e),t(n,e),t(i,e),e.isIterable=o,e.isKeyed=u,e.isIndexed=s,e.isAssociative=a,e.isOrdered=h,e.Keyed=r,e.Indexed=n,e.Set=i;var ar="@@__IMMUTABLE_ITERABLE__@@",hr="@@__IMMUTABLE_KEYED__@@",cr="@@__IMMUTABLE_INDEXED__@@",fr="@@__IMMUTABLE_ORDERED__@@",pr="delete",_r=5,lr=1<<_r,vr=lr-1,yr={},dr={value:!1},mr={value:!1},gr=0,wr=1,Sr=2,br="function"==typeof Symbol&&Symbol.iterator,xr="@@iterator",zr=br||xr;S.prototype.toString=function(){return"[Iterator]"},S.KEYS=gr,S.VALUES=wr,S.ENTRIES=Sr,S.prototype.inspect=S.prototype.toSource=function(){return this.toString()},S.prototype[zr]=function(){return this},t(M,e),M.of=function(){return M(arguments)},M.prototype.toSeq=function(){return this},M.prototype.toString=function(){return this.__toString("Seq {","}")},M.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},M.prototype.__iterate=function(t,e){return N(this,t,e,!0)},M.prototype.__iterator=function(t,e){return J(this,t,e,!0)},t(O,M),O.prototype.toKeyedSeq=function(){return this},t(k,M),k.of=function(){return k(arguments)},k.prototype.toIndexedSeq=function(){return this},k.prototype.toString=function(){return this.__toString("Seq [","]")},k.prototype.__iterate=function(t,e){return N(this,t,e,!1);
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox-gl-js/v0.12.0/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v0.12.0/mapbox-gl.css' rel='stylesheet' />
<link href='site.css' rel='stylesheet' />
</head>
<body class='unlimiter clip'>
<canvas id='canvas' class='contain z1 hidden'></canvas>
<div id='map' class='map'></div>
<div class='pin-bottomleft z1 pad1 col2'>
<div id='output-display' class='output-display round-top fill-darken2 dark small'></div>
<div id='history-controls' class='col12 clearfix mobile-cols round-bottom history-controls'>
<button id='undo' class='col6 button unround round-bottomleft keyline-right quiet'>Undo</button>
<button id='redo' class='col6 button unround round-bottomright quiet'>Redo</button>
</div>
</div>
<script src='bundle.js'></script>
</body>
</html>
#map { position:absolute; top:0; bottom:0; width:100%; }
.round-bottomleft { border-bottom-left-radius:3px; }
.round-bottomright { border-bottom-right-radius:3px; }
.history-controls { display:none; }
.history-controls.active { display:block; }
.draw-ctrl > button {
background-color:transparent;
border:none;
width:30px;
height:30px;
cursor:pointer;
}
.draw-ctrl > button.active {
background-color:rgba(0,0,0,0.25);
}
button:disabled {
background:#aaa;
}
@media only screen and (max-width:640px) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment