text: var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.data=(function(){var b="https://whosonfirst.mapzen.com/data/";var a={endpoint:function(c){if(c){mapzen.whosonfirst.log.info("set data endpoint to "+c);b=c}return b},id2abspath:function(e){var d=a.id2relpath(e);var c=a.endpoint()+d;return c},id2relpath:function(d){parent=a.id2parent(d);fname=a.id2fname(d);var c=parent+"/"+fname;return c},id2parent:function(d){str_id=new String(d);tmp=new Array();while(str_id.length){var c=str_id.substr(0,3);tmp.push(c);str_id=str_id.substr(3)}parent=tmp.join("/");return parent},id2fname:function(c){return c+".geojson"}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.log=(function(){var b=[];var a={show:function(){a.toggle(true)},hide:function(){a.toggle(false)},toggle:function(d){var f=document.getElementById("wof-log-container");if(!f){return false}var e=(d)?"display:block":"display:none";f.style=e},debug:function(c){a.log(c,"debug")},info:function(c){a.log(c,"info")},warning:function(c){a.log(c,"warning")},error:function(c){a.log(c,"error")},log:function(f,c){var e=new Date();b.push([c,f,e]);var d=a._render(f,c,e);a._attach(d)},_render:function(f,l,d){var g=mapzen.whosonfirst.php.htmlspecialchars(f);var e=mapzen.whosonfirst.php.htmlspecialchars(l);var k=document.createElement("li");k.setAttribute("class","wof-log-item wof-log-"+e);var j=document.createTextNode(" "+g);var i=document.createElement("span");i.setAttribute("class","wof-log-body");i.appendChild(j);var h=d.toISOString();h=mapzen.whosonfirst.php.htmlspecialchars(h);h=document.createTextNode(h+" "+l);var c=document.createElement("code");c.setAttribute("class","wof-log-ts");c.appendChild(h);k.appendChild(c);k.appendChild(i);return k},_attach:function(c){var d=document.getElementById("wof-log");if(!d){console.log("faile to locate #wof-log container");return false}d.insertBefore(c,d.childNodes[0]);return true}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.enmapify=(function(){var a={render_id:function(f,e,d){var b=a;if(!e){mapzen.whosonfirst.log.error("failed to enmapify because missing WOF ID");return false}if(!d){d=function(g){a.render_feature(f,g)}}var c=mapzen.whosonfirst.data.id2abspath(e);mapzen.whosonfirst.net.fetch(c,d)},render_feature_outline:function(c,b){mapzen.whosonfirst.leaflet.fit_map(c,b);mapzen.whosonfirst.leaflet.draw_poly(c,b,mapzen.whosonfirst.leaflet.styles.parent_polygon())},render_feature:function(c,j){mapzen.whosonfirst.leaflet.fit_map(c,j);var g=j.properties;var b=g["wof:id"];var f=g["wof:parent_id"];var h=mapzen.whosonfirst.data.id2abspath(b);var d=mapzen.whosonfirst.data.id2abspath(f);var e=function(l){mapzen.whosonfirst.leaflet.fit_map(c,l);l.properties["lflt:label_text"]=l.properties["wof:name"];mapzen.whosonfirst.leaflet.draw_poly(c,l,mapzen.whosonfirst.leaflet.styles.parent_polygon());var k=function(){mapzen.whosonfirst.log.error("failed to render "+d);i()};mapzen.whosonfirst.net.fetch(h,i,k)};var i=function(n){var p=n.properties;var w=n.geometry;var r=p["geom:latitude"];var q=p["geom:longitude"];var o="math centroid (shapely) is ";o+=r+", "+q;var v={type:"Feature",geometry:{type:"Point",coordinates:[q,r]},properties:{"lflt:label_text":o}};if(w.type=="Point"){var C=p["wof:name"];var o=C;o+=", whose centroid is ";o+=r+", "+q;v.properties["lflt:label_text"]=o;var A=mapzen.whosonfirst.leaflet.styles.geom_centroid();var k=mapzen.whosonfirst.leaflet.handlers.point(A);mapzen.whosonfirst.leaflet.draw_point(c,v,A,k);return}var l=true;mapzen.whosonfirst.leaflet.fit_map(c,n,l);n.properties["lflt:label_text"]="";mapzen.whosonfirst.leaflet.draw_bbox(c,n,mapzen.whosonfirst.leaflet.styles.bbox());n.properties["lflt:label_text"]=n.properties["wof:name"];mapzen.whosonfirst.leaflet.draw_poly(c,n,mapzen.whosonfirst.leaflet.styles.consensus_polygon());var B=function(){if(!G){var H=p["geom:latitude"];var I=p["geom:longitude"];var F="math centroid (shapely) is ";F+=H+", "+I;var G={type:"Feature",geometry:{type:"Point",coordinates:[I,H]},properties:{"lflt:label_text":F}}}var E=mapzen.whosonfirst.leaflet.styles.math_centroid();var D=mapzen.whosonfirst.leaflet.handlers.point(E);mapzen.whosonfirst.leaflet.draw_point(c,G,E,D);if((p["lbl:latitude"])&&(p["lbl:longitude"])){var H=p["lbl:latitude"];var I=p["lbl:longitude"];var J=p["src:lbl:centroid"]||p["src:centroid_lbl"]||"UNKNOWN";var F="label centroid (";F+=J;F+=") is ";F+=H+", "+I;var G={type:"Feature",geometry:{type:"Point",coordinates:[I,H]},properties:{"lflt:label_text":F}};var E=mapzen.whosonfirst.leaflet.styles.label_centroid();var D=mapzen.whosonfirst.leaflet.handlers.point(E);mapzen.whosonfirst.leaflet.draw_point(c,G,E,D)}};var t=p["wof:breaches"];var s=t.length;if(!s){B()}else{for(var z=0;z<s;z++){var m=t[z];var x=mapzen.whosonfirst.data.id2abspath(m);var y=mapzen.whosonfirst.leaflet.styles.breach_polygon();var u=function(I){var E=n.properties;var F=E["wof:name"];var D=I.properties;var H=D["wof:name"];var G=H+" breaches "+F;p["lflt:label_text"]=G;I.properties=p;mapzen.whosonfirst.leaflet.draw_poly(c,I,y);if(z==s){B()}};mapzen.whosonfirst.net.fetch(x,u)}}};if((!f)||(f==-1)){mapzen.whosonfirst.net.fetch(h,i)}else{mapzen.whosonfirst.net.fetch(d,e,function(){i()})}},enmapify_feature:function(b,c){}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.feedback=(function(){var b=undefined;var d=5000;var c=10000;var a={alert:function(e){this.append(e,"alert")},debug:function(e){this.append(e,"debug")},info:function(e){this.append(e,"info")},warning:function(e){this.append(e,"warning")},error:function(e){this.append(e,"warning")},persist:function(e){this.append(e,"persist")},append:function(g,m){mapzen.whosonfirst.log.log(g,m);var h=mapzen.whosonfirst.php.htmlspecialchars(g);var f=mapzen.whosonfirst.php.htmlspecialchars(m);var k=document.createTextNode(h);var e=new Date();var j=e.toISOString();var l=document.createElement("li");l.setAttribute("id",j);l.setAttribute("ts",j);l.setAttribute("class",f);l.appendChild(k);var i=a._list();i.appendChild(l);a.schedule();return j},schedule:function(){if(b){}var e=a;b=setTimeout(function(){e.prune()},d)},prune:function(){var e=new Date();var l=a._list();var g=l.children;var k=g.length;for(var j=0;j<k;j++){var o=g[j];if(!o){continue}var m=o.getAttribute("ts");var p=o.getAttribute("cls");if(p=="persist"){continue}var f=new Date(m);var n=e-f;var h=c;if(p=="alert"){h=h*2}if(n>h){l.removeChild(o)}}var g=l.children;var k=g.length;if(k){a.schedule()}},remove:function(g){var e=document.getElementById(g);if(e){var f=a._list();f.removeChild(e)}},_list:function(){var f=document.getElementById("whereami-feedback-list");if(!f){var f=document.createElement("ul");f.setAttribute("id","whereami-feedback-list");var e=document.getElementById("whereami-feedback");e.appendChild(f)}return f},log:function(f,e){if(mapzen.whosonfirst.log){mapzen.whosonfirst.log.log(f,e)}}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.geojson=(function(){var a={derive_bbox:function(b){if(b.bbox){return b.bbox}if(b.type=="FeatureCollection"){var d=b.features;var j=d.length;var k=undefined;var c=undefined;var m=undefined;var e=undefined;for(var h=0;h<j;h++){var o=a.derive_bbox(d[h]);var n,f,p,g=o;if((!k)||(n<k)){k=n}if((!c)||(f<c)){c=f}if((!m)||(p>m)){m=p}if((!e)||(g>e)){e=g}}return[k,c,m,e]}else{if(b.type=="Feature"){var l=b.geometry}else{}}}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.leaflet=(function(){var a={draw_point:function(f,b,e,d){var c=L.geoJson(b,{style:e,pointToLayer:d});c.addTo(f);return c},draw_poly:function(i,c,g){var d=L.geoJson(c,{style:g});try{var f=c.properties;var b=f["lflt:label_text"];if(b){d.bindLabel(b,{noHide:true})}}catch(h){mapzen.whosonfirst.log.error("failed to bind label because "+h)}d.addTo(i);return d},draw_bbox:function(d,b,e){var k=mapzen.whosonfirst.geojson.derive_bbox(b);if(!k){mapzen.whosonfirst.log.error("no bounding box to draw");return false}var k=b.bbox;var h=k[1];var c=k[0];var j=k[3];var f=k[2];var i={type:"Polygon",coordinates:[[[c,h],[c,j],[f,j],[f,h],[c,h]]]};var g={type:"Feature",geometry:i};return a.draw_poly(d,g,e)},fit_map:function(d,c,e){var i=mapzen.whosonfirst.geojson.derive_bbox(c);if(!i){mapzen.whosonfirst.log.error("no bounding box to fit");return false}if((i[1]==i[3])&&(i[2]==i[4])){d.setView([i[1],i[0]],14);return}var h=[i[1],i[0]];var f=[i[3],i[2]];var b=new L.LatLngBounds([h,f]);var g=d.getBounds();var j=true;if(!e){var j=false;if(b.getSouth()<=g.getSouth().toFixed(6)){j=true}else{if(b.getWest()<=g.getWest().toFixed(6)){j=true}else{if(b.getNorth()>=g.getNorth().toFixed(6)){j=true}else{if(b.getEast()>=g.getEast().toFixed(6)){j=true}else{}}}}}if(j){d.fitBounds(b)}}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.leaflet=mapzen.whosonfirst.leaflet||{};mapzen.whosonfirst.leaflet.styles=(function(){var a={bbox:function(){return{color:"#000000",weight:0.5,opacity:1,fillColor:"#000000",fillOpacity:0.4}},label_centroid:function(){return{color:"#fff",weight:3,opacity:1,radius:10,fillColor:"#ff0099",fillOpacity:0.8}},math_centroid:function(){return{color:"#fff",weight:2,opacity:1,radius:6,fillColor:"#ff7800",fillOpacity:0.8}},geom_centroid:function(){return{color:"#fff",weight:3,opacity:1,radius:10,fillColor:"#32cd32",fillOpacity:0.8}},search_centroid:function(){return{color:"#000",weight:2,opacity:1,radius:6,fillColor:"#0BBDFF",fillOpacity:1}},breach_polygon:function(){return{color:"#ffff00",weight:1.5,dashArray:"5, 5",opacity:1,fillColor:"#002EA7",fillOpacity:0.1}},consensus_polygon:function(){return{color:"#ff0066",weight:2,opacity:1,fillColor:"#ff69b4",fillOpacity:0.6}},pip_polygon:function(){return{color:"#ff0066",weight:2,opacity:1,fillColor:"#00308F",fillOpacity:0.5}},parent_polygon:function(){return{color:"#000",weight:1,opacity:1,fillColor:"#00308F",fillOpacity:0.5}}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.leaflet=mapzen.whosonfirst.leaflet||{};mapzen.whosonfirst.leaflet.handlers=(function(){var a={point:function(b){return function(f,h){var c=L.circleMarker(h,b);try{var g=f.properties;var d=g["lflt:label_text"];if(d){c.bindLabel(d,{noHide:false})}}catch(i){console.log("failed to bind label because "+i)}return c}}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.leaflet=mapzen.whosonfirst.leaflet||{};mapzen.whosonfirst.leaflet.tangram=(function(){var b="/spelunker/static/tangram/refill.yaml";var c={};var a={map_with_bbox:function(i,d,e,f,g){if((d==f)&&(e==g)){return a.map_with_latlon(i,d,e,14)}var h=a.map(i);h.fitBounds([[d,e],[f,g]]);return h},map_with_latlon:function(h,f,g,d){var e=a.map(h);e.setView([f,g],d);return e},map:function(f){if(!c[f]){var e=L.map(f);e.scrollWheelZoom.disable();var d=a.tangram();d.addTo(e);c[f]=e}return c[f]},tangram:function(f){var f=a.scenefile();var g=a.attributions();var d=a.render_attributions(g);var e=Tangram.leafletLayer({scene:f,numWorkers:2,unloadInvisibleTiles:false,updateWhenIdle:false,attribution:d});return e},scenefile:function(d){if(d){b=d}return b},attributions:function(){var d={Tangram:"https://mapzen.com/tangram","© OSM contributors":"http://www.openstreetmap.org/","Who's On First":"http://whosonfirst.mapzen.com/",Mapzen:"https://mapzen.com/"};return d},render_attributions:function(g){var i=[];for(var f in g){var h=g[f];var d=mapzen.whosonfirst.php.htmlspecialchars(f);if(!h){i.push(d);continue}var e='<a href="'+h+'" target="_blank">'+d+"</a>";i.push(e)}return i.join(" | ")}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.net=(function(){var b={};var a={encode_query:function(e){enc=new Array();for(var d in e){var c=e[d];c=encodeURIComponent(c);enc.push(d+"="+c)}return enc.join("&")},fetch:function(c,h,f){mapzen.whosonfirst.log.debug("fetch "+c);if(b[c]){mapzen.whosonfirst.log.debug("return "+c+" from cache");if(h){h(b[c])}return}var d=new XMLHttpRequest();d.onload=function(){try{var i=JSON.parse(this.responseText)}catch(j){mapzen.whosonfirst.log.error("failed to parse "+c+", because "+j);if(f){f()}return false}b[c]=i;if(h){h(i)}};try{d.open("get",c,true);d.send()}catch(g){mapzen.whosonfirst.log.error("failed to fetch "+c+", because ");mapzen.whosonfirst.log.debug(g);if(f){f()}}}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.pelias=(function(){var c="https://search.mapzen.com/v1/search";var b="";var a={search:function(h,i,e){var d=mapzen.whosonfirst.pelias.apikey();var g={text:h,api_key:d};g=mapzen.whosonfirst.net.encode_query(g);var f=mapzen.whosonfirst.pelias.endpoint()+"?"+g;mapzen.whosonfirst.log.info("geocode "+h);mapzen.whosonfirst.net.fetch(f,i,e)},endpoint:function(d){if(d){c=d}return c},apikey:function(d){if(d){b=d}return b}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.iplookup=(function(){var d="https://ip.dev.mapzen.com/";var c="";var a=true;var b={lookup:function(h,i,e){var g={raw:1};if(h){g.ip=h}g=mapzen.whosonfirst.net.encode_query(g);var f=mapzen.whosonfirst.iplookup.endpoint()+"?"+g;mapzen.whosonfirst.log.info("lookup IP "+h);mapzen.whosonfirst.net.fetch(f,i,e)},enabled:function(e){if(typeof(e)!="undefined"){a=(e)?true:false}return a},endpoint:function(f){if(f){d=f}return d},apikey:function(e){if(e){c=e}return c}};return b})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.php=(function(){var a={htmlspecialchars:function(d,j,h,c){var f=0,e=0,g=false;if(typeof j==="undefined"||j===null){j=2}d=d.toString();if(c!==false){d=d.replace(/&/g,"&amp;")}d=d.replace(/</g,"&lt;").replace(/>/g,"&gt;");var b={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(j===0){g=true}if(typeof j!=="number"){j=[].concat(j);for(e=0;e<j.length;e++){if(b[j[e]]===0){g=true}else{if(b[j[e]]){f=f|b[j[e]]}}}j=f}if(j&b.ENT_HTML_QUOTE_SINGLE){d=d.replace(/'/g,"&#039;")}if(!g){d=d.replace(/"/g,"&quot;")}return d}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.pip=(function(){var b="";var a={get_by_latlon:function(f,g,i,h,c){var e={latitude:f,longitude:g};if(i){e.placetype=i}e=mapzen.whosonfirst.net.encode_query(e);mapzen.whosonfirst.log.info("pip "+e);var d=a.endpoint()+"?"+e;mapzen.whosonfirst.net.fetch(d,h,c)},endpoint:function(c){if(c){b=c}return b}};return a})();var mapzen=mapzen||{};mapzen.whosonfirst=mapzen.whosonfirst||{};mapzen.whosonfirst.iamhere=(function(){var c="/tangram/refill.yaml";var f;var e={};var g=[];var b="disable_ip";var d="skip_notice";var a={init:function(){var u=mapzen.whosonfirst.iamhere.scenefile();mapzen.whosonfirst.leaflet.tangram.scenefile(u);var A=37.70120736474139;var w=-122.68707275390624;var k=37.80924146650164;var i=-122.21912384033203;f=mapzen.whosonfirst.leaflet.tangram.map_with_bbox("map",A,w,k,i);L.hash(f);f.on("load",function(s){a.update_location()});f.on("zoomend",function(s){a.update_location()});f.on("move",function(s){a.update_location()});f.on("dragend",function(s){a.reverse_geocode()});if(mapzen.whosonfirst.pelias.endpoint()){if(mapzen.whosonfirst.pelias.apikey()){var v=document.getElementById("find");v.onclick=a.search;var r=document.getElementById("search");r.style.cssText="display:inline;"}else{mapzen.whosonfirst.feedback.warning("Search is disabled because no API key has been defined")}}else{mapzen.whosonfirst.feedback.warning("Search is disabled because no API endpoint has been defined")}if(mapzen.whosonfirst.pip.endpoint()){var y=document.getElementById("findme");y.style.cssText="display:inline !important;";y.onclick=a.geolocate}else{mapzen.whosonfirst.feedback.warning("Reverse geocoding is disabled because no API endpoint has been defined")}var h=location.hash;var p=h.match(/^\#\d+\/(-?\d+(?:\.\d+))?\/(-?\d+(?:\.\d+))?/);var n=null;var j=null;if(p){n=p[1];j=p[2]}if(mapzen.whosonfirst.iplookup.enabled()){var q=document.getElementById("ip-lookups-enabled");var l=document.getElementById("ip-lookups-disabled");var x=function(){mapzen.whosonfirst.log.info("enabling IP lookups");a.set_cookie(b,0);q.style="display:block";l.style="display:none"};var o=function(){mapzen.whosonfirst.log.info("disbling IP lookups");a.set_cookie(b,1);q.style="display:none";l.style="display:block"};var t=document.getElementById("ip-lookups-on");var z=document.getElementById("ip-lookups-off");t.onclick=x;z.onclick=o;var m=a.cookiejar();if(parseInt(m[b])){l.style="display:block"}else{q.style="display:block"}if(!p){mapzen.whosonfirst.iamhere.iplookup()}}window.onresize=a.draw_crosshairs;window.ononline=a.on_online;window.onoffline=a.on_offline;if(navigator.onLine){a.on_online()}else{a.on_offline()}a.draw_crosshairs();a.update_location();a.reverse_geocode(n,j)},on_online:function(){mapzen.whosonfirst.feedback.info("you are in online mode");var j=document.getElementById("q");j.setAttribute("placeholder","search for a place");j.removeAttribute("disabled");j.value="";var i=document.getElementById("find");i.removeAttribute("disabled");var h=document.getElementById("findme");h.style.cssText="display:inline;color:#2E78A8"},on_offline:function(){mapzen.whosonfirst.feedback.info("you are in offline mode");var i=mapzen.whosonfirst.pelias.endpoint();if(!a.is_localhost(i)){var k=document.getElementById("q");k.setAttribute("placeholder","search is disabled");k.setAttribute("disabled","disabled");k.value="";var j=document.getElementById("find");j.style.cssText="display:none;";j.setAttribute("disabled","disabled")}var h=document.getElementById("findme");h.style.cssText="display:inline;color:#bbb"},is_localhost:function(h){var i=h.split(":");if(i[0]=="localhost"){return true}if(i[1]=="//localhost"){return true}return false},geolocate:function(){if(!navigator.onLine){mapzen.whosonfirst.feedback.alert("Unable to lookup your location because you are offline");return false}var k=mapzen.whosonfirst.feedback.persist("Looking up your location");var j=function(){mapzen.whosonfirst.feedback.remove(k)};var i=function(n){j();var l=n.coords.latitude;var m=n.coords.longitude;a.jump_to_point(l,m,16)};var h=function(l){j()};navigator.geolocation.getCurrentPosition(i,h)},iplookup:function(m){var k=a.cookiejar();if(parseInt(k[b])){mapzen.whosonfirst.log.info("skipping IP lookup because cookies say so");return}var i=function(o){mapzen.whosonfirst.log.info("IP lookup for "+o.ip+" is: "+o.wofid);if(o.geom_bbox){var s=o.geom_bbox;s=s.split(",");var n=[s[1],s[0]];var r=[s[3],s[2]];a.jump_to_bbox(n,r)}else{wofid=o.whosonfirst_id;var p=mapzen.whosonfirst.data.id2abspath(wofid);mapzen.whosonfirst.net.fetch(p,h,j)}var q=a.cookiejar();if(!parseInt(q[d])){a.iplookup_notice(o)}};var l=function(n){mapzen.whosonfirst.log.error("failed to lookup IP address")};var h=function(o){var q=mapzen.whosonfirst.geojson.derive_bbox(o);var n=[q[1],q[0]];var p=[q[3],q[2]];a.jump_to_bbox(n,p)};var j=function(n){mapzen.whosonfirst.log.error("failed to fetch record for IP address")};mapzen.whosonfirst.iplookup.lookup(m,i,l)},iplookup_enable:function(){a.set_cookie(b,0)},iplookup_disable:function(){a.set_cookie(b,1)},iplookup_notice:function(C){var E=function(){var I=document.getElementById("iamhere-modal-skip");var F=document.getElementById("iamhere-modal-disable");if((I)&&(I.checked)){a.set_cookie(d,1)}if((F)&&(F.checked)){a.iplookup_disable()}var H=document.getElementById("iamhere-modal");var G=H.parentElement;G.removeChild(H)};var w=function(){E()};var D=document.createElement("div");D.setAttribute("id","iamhere-modal");var x=document.createElement("div");x.setAttribute("id","iamhere-modal-text");var q=document.createElement("h4");q.appendChild(document.createTextNode('We have been "helpful" and auto-positioned the map for you...'));var B=document.createElement("div");var u="";if((C)&&(C.name)){var l=mapzen.whosonfirst.php.htmlspecialchars(C.name);u="They seem to think you are somewhere near or around "+l+"."}var r=["Using your computer's IP address we've asked the computer-robots-in-the-sky where in the world they think you might be right now.",u,"We've used this information to auto-position the map accordingly.","Sometimes the mappings from IP address to location are weird. Sometimes they are just wrong.",'Sometimes computers being "helpful" like this is weird and creepy so we\'ve added a setting to allow you to disable this feature in the future.',"IP lookups are a complicated business and we have written a blog post about them if you'd like to know more."];var p=r.join(" ");var m=document.createElement("p");m.appendChild(document.createTextNode(p));var A="https://mapzen.com/blog/missing-the-point/";var t=document.createElement("a");t.setAttribute("href",A);t.setAttribute("target","blog");t.appendChild(document.createTextNode(A));var k=document.createElement("p");k.setAttribute("class","iamhere-modal-blog");k.appendChild(t);var z=document.createElement("input");z.setAttribute("type","checkbox");z.setAttribute("id","iamhere-modal-skip");z.setAttribute("name","iamhere-modal-skip");var o=document.createElement("label");o.setAttribute("for","iamhere-modal-skip");o.appendChild(document.createTextNode("Do not show this notice again."));var j=document.createElement("p");j.appendChild(z);j.appendChild(o);var n=document.createElement("input");n.setAttribute("type","checkbox");n.setAttribute("id","iamhere-modal-disable");n.setAttribute("name","iamhere-modal-disable");var i=document.createElement("label");i.setAttribute("for","iamhere-modal-disable");i.appendChild(document.createTextNode("Please disable IP lookups altogether"));var h=document.createElement("p");h.appendChild(n);h.appendChild(i);B.appendChild(m);B.appendChild(k);B.appendChild(h);B.appendChild(j);x.appendChild(q);x.appendChild(B);var y=document.createElement("div");y.setAttribute("id","iamhere-modal-controls");var s=document.createElement("button");s.setAttribute("id","iamhere-modal-close-button");s.appendChild(document.createTextNode("close"));s.onclick=w;y.appendChild(s);D.appendChild(x);D.appendChild(y);var v=document.body;v.insertBefore(D,v.firstChild);return false},search:function(){var i=mapzen.whosonfirst.pelias.endpoint();if((!navigator.onLine)&&(!a.is_localhost(i))){mapzen.whosonfirst.feedback.alert("Unable to perform your search query because you seem to be offline");return false}var h=document.getElementById("q");h=h.value;if(h==""){mapzen.whosonfirst.feedback.alert("You forgot to say what you're searching for...");return false}a.geocode(h);return false},geocode:function(l){var h=mapzen.whosonfirst.php.htmlspecialchars(l);var j=mapzen.whosonfirst.feedback.persist("searching for "+h);var i=function(){mapzen.whosonfirst.feedback.remove(j)};var m=function(n){a.on_geocode(n)};var k=function(){};mapzen.whosonfirst.pelias.search(l,m,k)},on_geocode:function(h){var j=h.features;var n=j[0];var i=n.geometry;var k=i.coordinates;var l=k[1];var m=k[0];a.jump_to_point(l,m,12)},reverse_geocode:function(o,h){var n=mapzen.whosonfirst.pip.endpoint();if((!navigator.onLine)&&(!a.is_localhost(n))){mapzen.whosonfirst.feedback.alert("Reverse geocoding is disabled because you are offline");return false}if((!o)||(!h)){var p=f.getCenter();o=p.lat;h=p.lng}var q=function(i){a.on_reverse_geocode(i)};var s=function(i){var t=document.getElementById("whereami-reversegeo");t.style.cssText="display:inline !important;";t.innerHTML="the land of INVISIBLE ERROR CAT because the reverse geocoding failed"};var l=a.placetypes();var m=l.length;if(m==0){mapzen.whosonfirst.pip.get_by_latlon(o,h,null,q,s)}else{for(var k=0;k<m;k++){var r=l[k];mapzen.whosonfirst.pip.get_by_latlon(o,h,r,q,s)}}var j=document.getElementById("whereami-reversegeo");j.style.cssText="display:none !important;";j.innerHTML=""},on_reverse_geocode:function(k){var n=k.length;var o=e.length;mapzen.whosonfirst.log.info("reverse geocode possible results: "+n);var u={};for(var m=0;m<n;m++){var r=k[m];var x=r.Id;if(e[x]){u[x]=1}}for(var x in e){if(u[x]){continue}mapzen.whosonfirst.log.debug("remove layer for WOF ID "+x);var p=e[x];delete (e[x]);f.removeLayer(p)}var w=document.getElementById("whereami-reversegeo");w.style.cssText="display:inline !important;";if(!n){w.innerHTML="a place we don't know about";return}var q=k.length;var l=[];for(var m=0;m<q;m++){var r=k[m];var x=r.Id;var h=r.Name;var j=encodeURIComponent(x);var s=mapzen.whosonfirst.php.htmlspecialchars(h);var t='<a href="https://spelunker.whosonfirst.org/id/'+j+'/">';t+=s;t+="</a>";l.push(t);if(e[x]){continue}var v=function(z){var C=z.properties;var B=C["wof:id"];var i=C["wof:name"];z.properties["lflt:label_text"]=i;mapzen.whosonfirst.log.debug("draw layer for WOF ID "+B);var A=mapzen.whosonfirst.leaflet.styles.pip_polygon();var y=mapzen.whosonfirst.leaflet.draw_poly(f,z,A);e[B]=y};mapzen.whosonfirst.log.debug("fetch layer for WOF ID "+x);mapzen.whosonfirst.enmapify.render_id(f,x,v)}l=l.join(" or ");w.innerHTML=l},jump_to_point:function(i,j,h){f.setView([i,j],h);a.update_location();a.reverse_geocode()},jump_to_bbox:function(h,i){f.fitBounds([h,i]);a.update_location();a.reverse_geocode()},update_location:function(){var k=f.getCenter();var j=k.lat;var l=k.lng;j=j.toFixed(6);l=l.toFixed(6);var m=j+","+l;m=mapzen.whosonfirst.php.htmlspecialchars(m);var h=document.getElementById("whereami-latlon");h.innerHTML=m;var i=f.getZoom();i=mapzen.whosonfirst.php.htmlspecialchars(i);var h=document.getElementById("whereami-zoom");h.innerHTML=i},draw_crosshairs:function(){var o=document.getElementById("map");var j=o.getBoundingClientRect();var q=j.height;var k=j.width;var l=(q/2)-8;var n=(k/2);var h='"data:image/gif;base64,R0lGODlhEwATAKEBAAAAAP///////////yH5BAEKAAIALAAAAAATABMAAAIwlI+pGhALRXuRuWopPnOj7hngEpRm6ZymAbTuC7eiitJlNHr5tmN99cNdQpIhsVIAADs="';var i=[];i.push("position:absolute");i.push("top:"+l+"px");i.push("height:19px");i.push("width:19px");i.push("left:"+n+"px");i.push("margin-left:-8px;");i.push("display:block");i.push("background-position: center center");i.push("background-repeat: no-repeat");i.push("background: url("+h+")");i.push("z-index:200");i=i.join(";");var p=document.getElementById("crosshairs");p.style.cssText=i},scenefile:function(h){if(h){c=h}return c},placetypes:function(h){if((h)&&(Array.isArray(h))){g=h}return g},cookiejar:function(){var o={};var m=document.cookie;m=m.split(";");var n=m.length;for(var l=0;l<n;l++){var p=m[l].split("=");var j=p[0];var h=p[1];j=j.trim();o[j]=h}return o},set_cookie:function(j,i){j=j.trim();var l=[j,i].join("=");document.cookie=l;var h=mapzen.whosonfirst.php.htmlspecialchars(l);mapzen.whosonfirst.log.info("set cookie "+h)}};return a})();