-
Notifications
You must be signed in to change notification settings - Fork 6
/
iNat_map.html
1276 lines (1130 loc) · 79 KB
/
iNat_map.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Map of iNaturalist Observations" />
<title>Map of iNaturalist Observations</title>
<style>
body { height:100vh; width:100vw; margin:0px; font:10pt Sans-Serif;}
#mapid { height:100vh; width:100vw; position:absolute; top:0vh; left:0vw; background:darkgray; }
#info { padding:15px; }
h1 { margin-top:0px; }
a { text-decoration:none; }
</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<script>
// debug grid example from https://leafletjs.com/examples/extending/extending-2-layers.html
L.GridLayer.DebugCoords = L.GridLayer.extend({
createTile: function (coords) {
var tile = document.createElement('div');
tile.innerHTML = [coords.x, coords.y, coords.z].join(', ');
tile.style.outline = '1px solid red';
return tile;
}
});
L.gridLayer.debugCoords = function(opts) {
return new L.GridLayer.DebugCoords(opts);
};
// this allows a style filter to be applied to a basemap tile layer
L.TileLayer.StyleFilter = L.TileLayer.extend({
intialize: function (url, options) {
L.TileLayer.prototype.initialize.call(this, url, options);
},
styleFilter: function () {
var filters = this.options.filter || '';
return filters;
},
_initContainer: function () {
var tile = L.TileLayer.prototype._initContainer.call(this);
this._container.style.filter = this.styleFilter();
},
});
L.tileLayer.styleFilter = function (url, options) {
return new L.TileLayer.StyleFilter(url, options);
};
// this provides a way to get some USGS map images as tiles, as an alternative to WMS
// primary use case is when the WMS Server doesn't respond very quickly
// but this can also be used for other reasons, such as custom styling of the tiles
L.TileLayer.USGS = L.TileLayer.extend({
intialize: function (url, options) {
L.TileLayer.prototype.initialize.call(this, url, options);
},
getTileUrl: function (coords) {
var data = {
//r: Browser.retina ? '@2x' : '',
//s: this._getSubdomain(coords),
x: coords.x,
y: coords.y,
z: this._getZoomForUrl()
};
let mMax = 20037508.3428;
let mTile = 2*mMax/(Math.pow(2,data.z));
let bb = [
data.x*mTile-mMax,
-(data.y+1)*mTile+mMax,
(data.x+1)*mTile-mMax,
-data.y*mTile+mMax,
];
data['p'] = `&f=image&bboxSR=102100&imageSR=102100&size=${this._tileSize.x},${this._tileSize.y}&bbox=${bb[0]},${bb[1]},${bb[2]},${bb[3]}`;
if (this.options.renderingRule) { data['p'] += `&renderingRule=%7B"rasterFunction"%3A"${this.options.renderingRule}"%7D`; };
return this._url + data.p;
//return Util.template(this._url, Util.extend(data, this.options));
},
styleFilter: function () {
var filters = this.options.filter || '';
return filters;
},
_initContainer: function () {
var tile = L.TileLayer.prototype._initContainer.call(this);
this._container.style.filter = this.styleFilter();
},
});
L.tileLayer.usgs = function (url, options) {
return new L.TileLayer.USGS(url, options);
};
/*
https://github.com/mapbox/corslite
BSD 2-Clause License
Copyright (c) 2017, Mapbox
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function corslite(url, callback, cors) {
var sent = false;
if (typeof window.XMLHttpRequest === 'undefined') {
return callback(Error('Browser not supported'));
}
if (typeof cors === 'undefined') {
var m = url.match(/^\s*https?:\/\/[^\/]*/);
cors = m && (m[0] !== location.protocol + '//' + location.hostname +
(location.port ? ':' + location.port : ''));
}
var x = new window.XMLHttpRequest();
function isSuccessful(status) {
return status >= 200 && status < 300 || status === 304;
}
if (cors && !('withCredentials' in x)) {
// IE8-9
x = new window.XDomainRequest();
// Ensure callback is never called synchronously, i.e., before
// x.send() returns (this has been observed in the wild).
// See https://github.com/mapbox/mapbox.js/issues/472
var original = callback;
callback = function() {
if (sent) {
original.apply(this, arguments);
} else {
var that = this, args = arguments;
setTimeout(function() {
original.apply(that, args);
}, 0);
}
}
}
function loaded() {
if (
// XDomainRequest
x.status === undefined ||
// modern browsers
isSuccessful(x.status)) callback.call(x, null, x);
else callback.call(x, x, null);
}
// Both `onreadystatechange` and `onload` can fire. `onreadystatechange`
// has [been supported for longer](http://stackoverflow.com/a/9181508/229001).
if ('onload' in x) {
x.onload = loaded;
} else {
x.onreadystatechange = function readystate() {
if (x.readyState === 4) {
loaded();
}
};
}
// Call the callback with the XMLHttpRequest object as an error and prevent
// it from ever being called again by reassigning it to `noop`
x.onerror = function error(evt) {
// XDomainRequest provides no evt parameter
callback.call(this, evt || true, null);
callback = function() { };
};
// IE9 must have onprogress be set to a unique function.
x.onprogress = function() { };
x.ontimeout = function(evt) {
callback.call(this, evt, null);
callback = function() { };
};
x.onabort = function(evt) {
callback.call(this, evt, null);
callback = function() { };
};
// GET is the only supported HTTP Verb by XDomainRequest and is the
// only one supported here.
x.open('GET', url, true);
// Send the request. Sending data is not supported.
x.send(null);
sent = true;
return x;
}
if (typeof module !== 'undefined') module.exports = corslite;
/*
https://github.com/consbio/Leaflet.UTFGrid/blob/master/L.UTFGrid.js
Copyright (c) 2015 - 2017, Conservation Biology Institute
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//heavily modified from: https://raw.githubusercontent.com/danzel/Leaflet.utfgrid/leaflet-master/src/leaflet.utfgrid.js
//depends on corslite
L.UTFGrid = L.TileLayer.extend({
options: {
resolution: 4,
pointerCursor: true,
mouseInterval: 66 // Delay for mousemove events
},
_mouseOn: null,
_mouseOnTile: null,
_tileCharCode: null, // '<tileKey>:<charCode>' or null
_cache: null, // {<tileKey>: <utfgrid>}
_idIndex: null, // {<featureID>: {<tileKey1>: true, ...<tileKeyN>: true} }
_throttleMove: null, // holds throttled mousemove handler
//_throttleConnectEventHandlers: null, // holds throttled connection setup function
_updateCursor: function(){ }, //no-op, overridden below
onAdd: function (map) {
this._cache = {};
this._idIndex = {};
L.TileLayer.prototype.onAdd.call(this, map);
this._throttleMove = L.Util.throttle(this._move, this.options.mouseInterval, this);
if (this.options.pointerCursor) {
this._updateCursor = function(cursor) { this._container.style.cursor = cursor; }
}
map.on('boxzoomstart', this._disconnectMapEventHandlers, this);
// have to throttle or we get an immediate click event on boxzoomend
map.on('boxzoomend', this._throttleConnectEventHandlers, this);
this._connectMapEventHandlers();
},
onRemove: function () {
var map = this._map;
map.off('boxzoomstart', this._disconnectMapEventHandlers, this);
map.off('boxzoomend', this._throttleConnectEventHandlers, this);
this._disconnectMapEventHandlers();
this._updateCursor('');
L.TileLayer.prototype.onRemove.call(this, map);
},
createTile: function(coords) {
this._loadTile(coords);
return document.createElement('div'); // empty DOM node, required because this overrides L.TileLayer
},
setUrl: function(url, noRedraw) {
this._cache = {};
return L.TileLayer.prototype.setUrl.call(this, url, noRedraw);
},
_connectMapEventHandlers: function(){
this._map.on('click', this._onClick, this);
this._map.on('mousemove', this._throttleMove, this);
},
_disconnectMapEventHandlers: function(){
this._map.off('click', this._onClick, this);
this._map.off('mousemove', this._throttleMove, this);
},
_throttleConnectEventHandlers: function() {
setTimeout(this._connectMapEventHandlers.bind(this), 100);
},
_update: function (center, zoom) {
L.TileLayer.prototype._update.call(this, center, zoom);
},
_loadTile: function (coords) {
var url = this.getTileUrl(coords);
var key = this._tileCoordsToKey(coords);
var self = this;
if (this._cache[key]) { return }
corslite(url, function(err, response){
if (err) {
self.fire('error', {error: err});
return;
}
var data = JSON.parse(response.responseText);
self._cache[key] = data;
L.Util.bind(self._handleTileLoad, self)(key, data);
}, true);
},
_handleTileLoad: function(key, data) {
// extension point
},
_onClick: function (e) {
this.fire('click', this._objectForEvent(e));
},
_move: function (e) {
if (e.latlng == null){ return }
var on = this._objectForEvent(e);
if (on._tileCharCode !== this._tileCharCode) {
if (this._mouseOn) {
this.fire('mouseout', {
latlng: e.latlng,
data: this._mouseOn,
_tile: this._mouseOnTile,
_tileCharCode: this._tileCharCode
});
this._updateCursor('');
}
if (on.data) {
this.fire('mouseover', on);
this._updateCursor('pointer');
}
this._mouseOn = on.data;
this._mouseOnTile = on._tile;
this._tileCharCode = on._tileCharCode;
} else if (on.data) {
this.fire('mousemove', on);
}
},
_objectForEvent: function (e) {
if (!e.latlng) return; // keyboard <ENTER> events also pass through as click events but don't have latlng
var map = this._map,
point = map.project(e.latlng),
tileSize = this.options.tileSize,
resolution = this.options.resolution,
x = Math.floor(point.x / tileSize),
y = Math.floor(point.y / tileSize),
gridX = Math.floor((point.x - (x * tileSize)) / resolution),
gridY = Math.floor((point.y - (y * tileSize)) / resolution),
max = map.options.crs.scale(map.getZoom()) / tileSize;
x = (x + max) % max;
y = (y + max) % max;
var tileKey = this._tileCoordsToKey({z: map.getZoom(), x: x, y: y});
var data = this._cache[tileKey];
if (!data) {
return {
latlng: e.latlng,
data: null,
_tile: null,
_tileCharCode: null
};
}
var charCode = data.grid[gridY].charCodeAt(gridX);
var idx = this._utfDecode(charCode),
key = data.keys[idx],
result = data.data[key];
if (!data.data.hasOwnProperty(key)) {
result = null;
}
return {
latlng: e.latlng,
data: result,
id: (result)? result.id: null,
_tile: tileKey,
_tileCharCode: tileKey + ':' + charCode
};
},
_dataForCharCode: function (tileKey, charCode) {
var data = this._cache[tileKey];
var idx = this._utfDecode(charCode),
key = data.keys[idx],
result = data.data[key];
if (!data.data.hasOwnProperty(key)) {
result = null;
}
return result;
},
_utfDecode: function (c) {
if (c >= 93) {
c--;
}
if (c >= 35) {
c--;
}
return c - 32;
},
_utfEncode: function (c) {
//reverse of above, returns charCode for c
//derived from: https://github.com/mapbox/glower/blob/mb-pages/src/glower.js#L37
var charCode = c + 32;
if (charCode >= 34) {
charCode ++;
}
if (charCode >= 92) {
charCode ++;
}
return charCode;
}
});
L.utfGrid = function (url, options) {
return new L.UTFGrid(url, options);
};
L.UTFGridCanvas = L.UTFGrid.extend({
options: {
idField: 'ID', // Expects UTFgrid to have a property 'ID' that indicates the feature ID
buildIndex: true, // requires above field to be set properly
fillColor: 'black',
shadowBlur: 0, // Number of pixels for blur effect
shadowColor: null, // Color for shadow, if present. Defaults to fillColor.
debug: false // if true, show tile borders and tile keys
},
_adjacentTiles: null,
onAdd: function (map) {
this._adjacentTiles = [];
L.UTFGrid.prototype.onAdd.call(this, map);
},
createTile: function(coords) {
this._loadTile(coords);
var tile = document.createElement('canvas');
tile.width = tile.height = this.options.tileSize;
if (this.options.debug) {
this._drawDefaultTile(tile.getContext('2d'), this._tileCoordsToKey(coords));
}
return tile;
},
_connectMapEventHandlers: function(){
L.UTFGrid.prototype._connectMapEventHandlers.call(this);
this.on('mouseover', this._handleMouseOver, this);
this.on('mouseout', this._handleMouseOut, this);
},
_disconnectMapEventHandlers: function(){
L.UTFGrid.prototype._disconnectMapEventHandlers.call(this);
this.off('mouseover', this._handleMouseOver, this);
this.off('mouseout', this._handleMouseOut, this);
},
_handleMouseOver: function (e) {
if (e._tile == null || e._tileCharCode == null){ return }
this._clearAdjacentTiles();
// currently over this tile:
var curTile = e._tile;
this._drawTile(curTile, parseInt(e._tileCharCode.split(':')[3]));
if (e.data && this._idIndex) {
// draw adjacent tiles
var id = e.data[this.options.idField];
var zoomLevel = curTile.split(':')[2];
if (!(id && this._idIndex[id] && this._idIndex[id][zoomLevel])) { return }
var idx = this._idIndex[id][zoomLevel];
for (var tileKey in idx) {
//TODO: screen out any tiles that are not currently visible?
if (tileKey !== curTile) {
this._drawTile(tileKey, idx[tileKey]);
this._adjacentTiles.push(tileKey);
}
}
}
},
_handleMouseOut: function (e) {
this._resetTile(e._tile);
this._clearAdjacentTiles();
},
_clearAdjacentTiles: function() {
// clear out any adjacent tiles that were drawn
if (this._adjacentTiles) {
for (var i = 0; i < this._adjacentTiles.length; i++) {
this._resetTile(this._adjacentTiles[i]);
}
this._adjacentTiles = [];
}
},
_handleTileLoad: function(tileKey, data) {
// build index: {<id: {zoomLevel: {tileKey: tileCharCode} } }
if (this.options.buildIndex) {
var id, props, idx;
var idField = this.options.idField;
var zoomLevel = tileKey.split(':')[2];
for (var i = 0; i < data.keys.length; i++) {
props = data.data[data.keys[i]];
if (props) {
id = props[idField];
if (id) {
if (this._idIndex[id] == null) {
this._idIndex[id] = {};
}
idx = this._idIndex[id];
if (idx[zoomLevel] == null) {
idx[zoomLevel] = {};
}
idx[zoomLevel][tileKey] = this._utfEncode(i);
}
}
}
}
},
_drawTile: function(tileKey, charCode) {
// for a given tile, find all pixels that match character and repaint
// TODO: request animation frame?
if (this._tiles[tileKey] == null){ return }
var canvas = this._tiles[tileKey].el;
var ctx = canvas.getContext('2d');
this._resetTile(tileKey);
var grid = this._cache[tileKey].grid;
ctx.fillStyle = this.options.fillColor;
var dim = this.options.tileSize / this.options.resolution;
// TODO: order of traversal here may be backwards? Do y then x? (are data column major or row major?)
//modified slightly from: https://github.com/mapbox/glower/blob/mb-pages/src/glower.js
for (var x = 0; x < dim; x++) {
for (var y = 0; y < dim; y++) {
if (grid[y].charCodeAt(x) === charCode) {
var sweep = 1;
while (y < 63 && grid[y + 1].charCodeAt(x) === charCode) {
y++;
sweep++;
}
ctx.fillRect(x * 4, (y * 4) - ((sweep - 1) * 4), 4, 4 * sweep);
}
}
}
if (this.options.shadowBlur) {
this._addShadow(canvas, ctx);
}
},
_resetTile: function(tileKey) {
// clear the canvas
if (this._tiles[tileKey] == null){ return }
var tile = this._tiles[tileKey].el;
tile.width = this.options.tileSize; // hard reset of canvas
if (this.options.debug) {
this._drawDefaultTile(tile.getContext('2d'), tileKey);
}
},
_drawDefaultTile: function(ctx, tileKey) {
// if this.options.debug, add tileKey text and borders
ctx.fillStyle = 'black';
ctx.fillText(tileKey, 20, 20);
ctx.strokeStyle = 'red';
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(255, 0);
ctx.lineTo(255, 255);
ctx.lineTo(0, 255);
ctx.closePath();
ctx.stroke();
},
_addShadow: function(canvas, ctx) {
ctx.shadowBlur = this.options.shadowBlur;
ctx.shadowColor = this.options.shadowColor || this.options.fillColor;
//Blur effect copied from glower - https://github.com/cutting-room-floor/glower/blob/mb-pages/src/glower.js#L108
ctx.globalAlpha = 0.7;
ctx.globalCompositeOperation = 'lighter';
var a = 1;
ctx.drawImage(canvas, -a, -a);
ctx.drawImage(canvas, a, a);
ctx.drawImage(canvas, 0, -a);
ctx.drawImage(canvas, -a, 0);
ctx.globalAlpha = 1;
}
});
L.utfGridCanvas = function (url, options) {
return new L.UTFGridCanvas(url, options);
};
// iNaturalist UTFGrid Compare
function freplacexyz(url,x,y,z) {
url = url.replace('{x}',x);
url = url.replace('{y}',y);
url = url.replace('{z}',z);
return url;
};
function fgetutfgrid(url) {
return fetch(url)
.then((response) => {
if (!response.ok) { throw new Error(response.status+': '+response.statusText); };
return response.json();
})
// .then((data) => { return data; })
.catch((err) => { console.error(err); });
};
L.GridLayer.UTFGridCompare = L.GridLayer.extend({
createTile: function (coords, done) {
var tile = document.createElement('canvas');
var tileSize = this.getTileSize();
tile.width = tileSize.x;
tile.height = tileSize.y;
var cellsPerTile = {x:64,y:64};
var cellSize = {x:tileSize.x/cellsPerTile.x,y:tileSize.y/cellsPerTile.y};
var ctx = tile.getContext('2d');
// default marker setups
var dmarker = {type:'relative',offset:{x:0,y:0},size:0.75,opacity:0.5};
var marker = null;
if (this.options.marker) {
marker = this.options.marker;
marker.type = marker.type || dmarker.type;
marker.size = marker.size || dmarker.size;
marker.offset = marker.offset || dmarker.offset;
marker.opacity = marker.opacity || dmarker.opacity;
}
else { marker = dmarker };
var offset = marker.offset;
// get UTFgrids
url0 = this.options.urlcompare;
url1 = this.options.url;
var prom0 = fgetutfgrid(freplacexyz(url0,coords.x,coords.y,coords.z));
var prom1 = fgetutfgrid(freplacexyz(url1,coords.x,coords.y,coords.z));
Promise.all([prom0,prom1]).then(function(utfgrid) {
//draw markers on the tile canvas
//note that this code was originally written to assume a 64x64 UTFgrid.
//although the UTFgrid is still 64x64, the associated "grid tile" is actually only 32x32.
//theoretically, a 2x2 set of cells from the UTFgrid should correspond to a single cell from the "grid tile"; however, that is not actually the case (see https://forum.inaturalist.org/t/open-test-of-map-tile-improvements/7833/88).
//so this code attempts to mimic a 32x32 "grid tile" by using the bottom-right cell from each 2x2 set of UTFgrid cells.
//for (cx=0;cx<cellsPerTile.x;cx++) {
for (cx=0;cx<cellsPerTile.x/2;cx++) {
//for (cy=0;cy<cellsPerTile.y;cy++) {
for (cy=0;cy<cellsPerTile.y/2;cy++) {
//var cell = {x:cx,y:cy};
var cell = {x:cx*2+1,y:cy*2+1};
//for details about decoding the UTFgrid, see https://github.com/mapbox/utfgrid-spec/blob/master/1.2/utfgrid.md
var d = [];
for (u=0;u<utfgrid.length;u++) {
var i = utfgrid[u].grid[cell.y].charCodeAt(cell.x);
i = i-((i>=93)?34:(i>=35)?33:32);
d.push(utfgrid[u].data[utfgrid[u].keys[i]]);
};
for (j=0;j<d.length;j++) { d[j] = d[j] ? d[j].cellCount||0 : 0; } // set d = cellCount (set to 0 if undefined)
var markerColor = 0; // default to black
ctx.beginPath();
var circleRadius = cellSize.x*marker.size;
ctx.arc(cell.x*cellSize.x+offset.x,cell.y*cellSize.y+offset.y,circleRadius,0,2*Math.PI,false);
if ( d[0]<=0 ) { markerColor = 'rgba(128,128,128,0.00)'; } // no color
// else if ( d[1]<=0 ) { markerColor = `rgba(0,0,255,${marker.opacity})`; } // blue
else {
var f = d[1]/d[0];
f = (f<=0)?1:(f>=1)?0:1-f;
markerColor = `hsla(${(f*240)},100%,50%,${marker.opacity})`; // high (1.0) is red, low (0.0) is blue
ctx.fillStyle = markerColor;
ctx.fill();
};
ctx.strokeStyle = markerColor;
ctx.stroke();
};
};
});
// asynchronous call
setTimeout(function() {
done(null, tile);
}, 1000);
return tile;
}
});
L.gridLayer.utfGridCompare = function (options) {
return new L.GridLayer.UTFGridCompare(options);
};
</script>
</head>
<body>
<script>
//get parameters from the url
let winurlstr = window.location.href;
let winurlsearchstr = window.location.search;
let winurlexsearchstr = winurlstr.replace(winurlsearchstr,'');
let winurlparams = new URLSearchParams(winurlsearchstr.substring(1));
var taxon_id = winurlparams.get('taxon_id');
taxon_id = (taxon_id===null?null:taxon_id.split(',')[0]);
var place_id = winurlparams.get('place_id');
place_id = (place_id===null?null:place_id.split(',')[0]);
var centerlat = winurlparams.get('centerlat');
var centerlng = winurlparams.get('centerlng');
var defaultzoom = winurlparams.get('defaultzoom');
var showtaxonplace = winurlparams.get('showtaxonplace') || 'false';
var showtaxonrange = winurlparams.get('showtaxonrange') || 'false';
var showexpectednearby = winurlparams.get('showexpectednearby') || 'false';
var showplace = winurlparams.get('showplace') || 'false';
var view = winurlparams.get('view') || 'default';
var compexclparam = winurlparams.get('compare_exclude_param');
var thresholded = winurlparams.get('thresholded') || 'true'; // even though the default in the API is false, set the default to true, since we're going to usually want to see Expected Nearby rather than Unthresholded
winurlparams.delete('centerlat');
winurlparams.delete('centerlng');
winurlparams.delete('defaultzoom');
winurlparams.delete('showtaxonplace');
winurlparams.delete('showtaxonrange');
winurlparams.delete('showexpectednearby');
winurlparams.delete('showplace');
winurlparams.delete('view');
winurlparams.delete('compare_exclude_param');
winurlparams.delete('thresholded');
let compareurlparams = new URLSearchParams(winurlparams);
if (compexclparam) { for (p of compexclparam.split(',')) { compareurlparams.delete(p); }; };
function fdate(str) {
str = str.replace(/t/i,' '); //replaces T (case insensitive) with a space
str = str.replace(/([+-]\d{2}\:?\d{2})/,' ($1)'); //puts parenthesis around time zone offset
str = str.replace(/z/i,' (+00:00)'); //replaces Z (case insensitve) with UTC
str = str.replace('+00:00','±00:00');
return str;
};
function fround(num,places) {
var n = num*1;
return n.toFixed(places);
};
function furl(url,txt=url) { return '<a href="'+url+'">'+txt+'</a>'; };
function faddelem(etype,eparent=null,eclass=null,eid=null,ehtml=null,etext=null) {
var eobj = document.createElement(etype);
if (eclass!==null) { eobj.classList = eclass };
if (eid!==null) { eobj.id = eid };
if (ehtml!==null) { eobj.innerHTML = ehtml };
if (etext!==null) { eobj.innerText = etext };
if (eparent!==null) { eparent.appendChild(eobj); };
return eobj;
};
function ffetch(url) {
return fetch(url)
.then((response) => {
if (!response.ok) { throw new Error(response.status+': '+response.statusText); };
return response.json();
})
.then((data) => { return data; })
.catch((err) => { console.error(err); });
};
let inat_urlbase = 'https://api.inaturalist.org/v1/';
if (winurlparams=="") {
var div = faddelem('div',document.body,null,'info');
faddelem('h1',div,null,null,'Map of iNaturalist Observations');
faddelem('p',div,null,null,'This page displays a map of iNaturalist observations. Clicking on any observation marker opens a pop-up window which provides basic details of the observation');
faddelem('p',div,null,null,'This page requires that you input at least one filter parameter in the URL. For example, if the URL of this page is '+winurlexsearchstr +', and you want to see research grade ocotillo observations, then you would navigate to '+furl(winurlexsearchstr+'?taxon_id=49325&quality_grade=research')+' in your web browser. This page will accept most parameters documented for the '+ furl(inat_urlbase+'docs/#!/Observations/get_observations','iNaturalist API Get Observations Endpoint')+ '.');
faddelem('p',div,null,null,'If place_id is included as a parameter, then the place polygon will be available as an optional layer in the map. If taxon_id is included as a parameter, then taxon places and taxon range will be available as optional layers in this map (if they have been defined in iNaturalist).');
faddelem('p',div,null,null,'If a special "view" parameter is set to "=elevation", then the map will display with the USGS topo basemap (with contours in feet) by default, and the info pop-ups will include elevation (sourced from the '+furl('https://epqs.nationalmap.gov/','USGS elevation point query service')+'). USGS does not provide elevations outside of the United States. In cases where the USGS returns no data, the page will fall back to the '+furl('https://open-elevation.com/','Open-Elevation API')+'. As an example, if you want to see mountain goats in the United States, then you would navigate to '+furl(winurlexsearchstr+'?view=elevation&taxon_id=42414&place_id=1')+' in your web browser.');
faddelem('p',div,null,null,'If a special "view" parameter is set to "=ecolandunit", then the map will display with a USGS Ecological Land Unit overlay on a dark basemap by default, and the info pop-ups will include USGS ELU information (sourced from '+furl('https://www.usgs.gov/centers/geosciences-and-environmental-change-science-center/science/global-ecosystems','USGS Global Ecosystems')+'). This should work on any point of land worldwide. As an example, if you want to see maples around the world, then you would navigate to '+furl(winurlexsearchstr+'?view=ecolandunit&taxon_id=47727&defaultzoom=2')+' in your web browser.');
faddelem('p',div,null,null,'If a special "view" parameter is set to "=heatmap", then the map will show a heatmap view of observations on a muted-color basemap. By default, clicking the heatmap will not open a info pop-up. As an example, to get an idea of where user kueda has made observations, you would navigate to '+furl(winurlexsearchstr+'?view=heatmap&user_id=kueda')+' in your web browser.');
faddelem('p',div,null,null,'If a special "view" parameter is set to "=subsetratio", then the map will compare a gridded view of one set of observations (the subset, defined in the URL) to another set (the superset, defined by a required special "compare_exclude_param" parameter, which removes one or more parameters from the subset parameter list). The color of the markers will vary based on the ratio of subset to superset for each cell (red=1.0 and blue=0.0), and they will appear on top of a gray basemap. As an example, to compare research grade plant observations to verifiable plant observations, you would navigate to '+furl(winurlexsearchstr+'?view=subsetratio&verifiable=true&quality_grade=research&taxon_id=47126&compare_exclude_param=quality_grade')+' in your web browser. Note that if you use exclusion filter parameters (ex. not_user_id) in your subset and remove them from the superset, then you may get unexpected results (because the subset would no longer be a true subset).'); faddelem('p',div,null,null,'There are 2 final sets of special parameters: centerlat, centerlng, and defaultzoom can be used to set the default map center and zoom level when the map is first opened; and showtaxonplace, showtaxonrange, showexpectednearby, and showplace can be set to true to display specific layers by default.');
}
else {
var mapdiv = faddelem('div',document.body,null,'mapid');
// iNat Observation Layer, using grid markers at lower zooms and points at higher zooms
// let inat_circles = {url:inat_urlbase+'colored_heatmap/{z}/{x}/{y}.png',description:'iNaturalist Observations (Density Circles)',attribution:'<a href="https://api.inaturalist.org/v1/docs/#!/Observation_Tiles/get_colored_heatmap_zoom_x_y_png">iNaturalist observation data</a>'};
let inat_heat = {url:inat_urlbase+'heatmap/{z}/{x}/{y}.png',description:'iNaturalist Observations (Heatmap)',attribution:'<a href="https://api.inaturalist.org/v1/docs/#!/Observation_Tiles/get_heatmap_zoom_x_y_png">iNaturalist observation data</a>'};
// let gbif_density_point_py = {url:'https://api.gbif.org/v2/map/occurrence/density/{z}/{x}/{y}@1x.png?srs=EPSG:3857&style=purpleYellow.point&publishingOrg=28eb1a3f-1c15-4a95-931a-4af90ecb574d',description:'iNaturalist Observations in GBIF',attribution:'<a href="https://www.gbif.org/developer/maps">GBIF occurrence data</a>'};
// var l_inat_circles = L.tileLayer(inat_circles.url+'?'+winurlparams,{minZoom:2, maxZoom:20, attribution:inat_circles.attribution});
var l_inat_heat = L.tileLayer(inat_heat.url+'?'+winurlparams,{minZoom:0, maxZoom:20, attribution:inat_heat.attribution});
// var l_gbif = L.tileLayer(gbif_density_point_py.url,{minZoom:2, maxZoom:20, attribution:gbif_density_point_py.attribution});
let inat_points = {url:inat_urlbase+'points/{z}/{x}/{y}.png',description:'iNaturalist Observations (Points)',attribution:'<a href="https://api.inaturalist.org/v1/docs/#!/Observation_Tiles/get_points_zoom_x_y_png">iNaturalist observation data</a>'};
let inat_grid = {url:inat_urlbase+'grid/{z}/{x}/{y}.png',description:'iNaturalist Observations (Grid)',attribution:'<a href="https://api.inaturalist.org/v1/docs/#!/Observation_Tiles/get_grid_zoom_x_y_png">iNaturalist observation data</a>'};
var l_inat_points = L.tileLayer(inat_points.url+'?'+winurlparams,{minZoom:0,maxZoom:20, attribution:inat_points.attribution});
var l_inat_grid = L.tileLayer(inat_grid.url+'?'+winurlparams,{minZoom:0,maxZoom:20,attribution:inat_grid.attribution});
var l_inat_obs_points = L.tileLayer(inat_points.url+'?'+winurlparams,{minZoom:10,maxZoom:20, attribution:inat_points.attribution});
var l_inat_obs_grid = L.tileLayer(inat_grid.url+'?'+winurlparams,{minZoom:2,maxZoom:9,attribution:inat_grid.attribution});
var g_inat_obs = L.layerGroup([l_inat_obs_grid,l_inat_obs_points]);
// iNat Observation Layer mods
var l_inat_heat_mod_transparent = L.tileLayer.styleFilter(inat_heat.url+'?'+winurlparams,{minZoom:0, maxZoom:20, attribution:inat_heat.attribution, filter:'opacity(50%)'});
// iNat UTFGrid Selection
// (hover to see selected area, and click to view selected observation)
async function fpopup(obs,count) {
var s = (obs.photos.length==0) ? '[No Photo]' : '<img src="'+obs.photos[0].url+'" />';
s += (obs.photos.length>1) ? ' ['+obs.photos.length+']' : '';
s += '<br />observation #: <a target="_blank" href="'+obs.uri+'">'+obs.id+'</a> (grade: '+obs.quality_grade+')';
s += '<br />taxon: ' + ((obs.taxon==null) ? '[Unknown]' : obs.taxon.preferred_common_name ? (obs.taxon.preferred_common_name+' ('+obs.taxon.name+')') : obs.taxon.name );
s += '<br />observer: '+obs.user.login;
// s += '<br />location: '+obs.place_guess;
s += '<br />coordinates: '+fround(obs.geojson.coordinates[1],6)+', '+fround(obs.geojson.coordinates[0],6);
s += (obs.positional_accuracy==null) ? '' : ' ('+fround(obs.positional_accuracy,1)+'m)';
if (view==='elevation') {
var elevationurl = 'https://epqs.nationalmap.gov/v1/json?y='+obs.geojson.coordinates[1]+'&x='+obs.geojson.coordinates[0]+'&output=json&units=Feet';
var elevation = await ffetch(elevationurl)
.then((data) => {
return data;
});
if ((elevation?elevation.value:-1000000)>-1000000) { s += '<br />elevation: '+ (fround(elevation.value,1)+'ft, '+ fround(elevation.value*0.3048,1) + 'm'); }
else {
var elevationurl_fallback = 'https://api.open-elevation.com/api/v1/lookup?locations='+obs.geojson.coordinates[1]+','+obs.geojson.coordinates[0];
var elevation_fallback = await ffetch(elevationurl_fallback)
.then((data) => {
return data?.results[0];
});
s += '<br />elevation: '+ (elevation_fallback?(elevation_fallback.elevation+'m'):'[Unknown]');
};
};
s += '<br />observed: '+((obs.time_observed_at==null) ? ((obs.observed_on==null) ? '[Unknown]': obs.observed_on) : fdate(obs.time_observed_at));
s += '<br />created: '+((obs.created_at==null) ? obs.created_at_details.date : fdate(obs.created_at));
s += '<br />last updated: '+fdate(obs.updated_at);
// if (obs.description==null) {}
// else if (obs.description.length < 200) {s += '<br />'+obs.description }
// else {s += '<br />'+(obs.description.substring(0,191)+'... (more)')};
if (view==='ecolandunit') {
function latlngtoxy(latlng) { return L.CRS.EPSG3857.project(latlng); };
let mapExtent = mymap.getBounds();
let pointXY = latlngtoxy(L.latLng(obs.geojson.coordinates[1],obs.geojson.coordinates[0]));
var ecoluurl = `https://rmgsc.cr.usgs.gov/arcgis/rest/services/globalelus/MapServer/identify?geometry={"x":${pointXY.x},"y":${pointXY.y}}&geometryType=esriGeometryPoint&sr=102100&layers=all:4&tolerance=3&mapExtent=${latlngtoxy(mapExtent.getNorthWest()).x},${latlngtoxy(mapExtent.getNorthWest()).y},${latlngtoxy(mapExtent.getSouthEast()).x},${latlngtoxy(mapExtent.getSouthEast()).y}&imageDisplay=1,1,96&returnGeometry=false&returnZ=false&returnM=false&returnUnformattedValues=false&f=pjson`;
var ecoludetails = await ffetch(ecoluurl)
.then((data) => {
return data.results[0].attributes;
});
s += '<hr /><details>'
s += '<summary>Ecological Land Unit: ' + (ecoludetails ? (ecoludetails['Raster.ELU'] ?? 'N/A') : 'N/A') + '</summary>';
s += '- Bioclimate: ' + (ecoludetails ? (ecoludetails['Raster.ELU_Bio_De'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Cover: ' + (ecoludetails ? (ecoludetails['Raster.ELU_GLC_De'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Form: ' + (ecoludetails ? (ecoludetails['Raster.ELU_LF_Des'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Lithology: ' + (ecoludetails ? (ecoludetails['Raster.ELU_Lit_De'] ?? 'N/A') : 'N/A');
s += '</details>';
s += '<hr /><details>';
s += '<summary>Ecological Facet: ' + (ecoludetails ? (ecoludetails['Raster.EF'] ?? 'N/A') : 'N/A') + '</summary>';
s += '- Bioclimate: ' + (ecoludetails ? (ecoludetails['Raster.EF_Bio_Des'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Cover: ' + (ecoludetails ? (ecoludetails['Raster.EF_GLC_Des'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Form: ' + (ecoludetails ? (ecoludetails['Raster.EF_LF_Desc'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Lithology: ' + (ecoludetails ? (ecoludetails['Raster.EF_Lit_Des'] ?? 'N/A') : 'N/A');
s += '</details>';
var ecosysdetails;
let contSets = ['US','SA','AF'];
for (let cont of contSets) {
var ecosysurl = `https://rmgsc.cr.usgs.gov/arcgis/rest/services/cont${cont}/MapServer/identify?geometry={"x":${pointXY.x},"y":${pointXY.y}}&geometryType=esriGeometryPoint&sr=102100&layers=all:0,1,2,3,4&tolerance=3&mapExtent=${latlngtoxy(mapExtent.getNorthWest()).x},${latlngtoxy(mapExtent.getNorthWest()).y},${latlngtoxy(mapExtent.getSouthEast()).x},${latlngtoxy(mapExtent.getSouthEast()).y}&imageDisplay=1,1,96&returnGeometry=false&returnZ=false&returnM=false&returnUnformattedValues=false&f=pjson`;
ecosysdetails = await ffetch(ecosysurl)
.then((data) => {
return ((data.results?.length||0)===0) ? null : data.results;
});
if (ecosysdetails) { break; };
};
if (ecosysdetails) {
s += '<hr /><details>';
s += '<summary>Ecosystem: ' + (ecosysdetails[0]?.attributes ? (ecosysdetails[0]?.attributes['Raster.code_desc'] ?? 'N/A') : 'N/A') + '</summary>';
s += '- Bioclimate: ' + (ecosysdetails[1].attributes ? (ecosysdetails[1].attributes['Raster.code_desc'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Form: ' + (ecosysdetails[2]?.attributes ? (ecosysdetails[2]?.attributes['Raster.code_desc'] ?? 'N/A') : 'N/A');
s += '<br /> - Land Lithology: ' + (ecosysdetails[3]?.attributes ? (ecosysdetails[3]?.attributes['Raster.code_desc'] ?? 'N/A') : 'N/A');
if (ecosysdetails.length>4) {s += '<br /> - Topographic Position: ' + (ecosysdetails[4]?.attributes ? (ecosysdetails[4]?.attributes['Raster.code_desc'] ?? 'N/A') : 'N/A'); };
s += '</details>';
};
};
if (count>1) {
s += '<hr />'
s += `This marker also denotes ${count-1} older observation${(count>2)?'s':''}.`
};
L.popup().setLatLng([obs.geojson.coordinates[1],obs.geojson.coordinates[0]])
.setContent(s).openOn(mymap);
};
var u_inat_options = {
resolution: 4,
pointerCursor: true,
mouseInterval: 66, // Delay for mousemove events
minZoom:0,
maxZoom:20,
};
var u_inat_points = L.utfGrid(inat_urlbase+'points/{z}/{x}/{y}.grid.json?'+winurlparams, { ...u_inat_options, minZoom:10 });
u_inat_points.on("click", function(e) { // "mouseover" and "mouseout" events not used here
if (e.data) {
Promise.all([
ffetch(inat_urlbase+'observations/'+e.data.id),
Promise.resolve(e.data.cellCount)
])
.then ((data) => { fpopup(data[0].results[0],data[1]); });
};
});
var u_inat_points_all = L.utfGrid(inat_urlbase+'points/{z}/{x}/{y}.grid.json?'+winurlparams, u_inat_options);
u_inat_points_all.on("click", function(e) { // "mouseover" and "mouseout" events not used here
if (e.data) {
Promise.all([
ffetch(inat_urlbase+'observations/'+e.data.id),
Promise.resolve(e.data.cellCount)
])
.then ((data) => { fpopup(data[0].results[0],data[1]); });
};
});
var u_inat_grid = L.utfGrid(inat_urlbase+'grid/{z}/{x}/{y}.grid.json?'+winurlparams, { ...u_inat_options, minZoom:2, maxZoom:9 });
u_inat_grid.on("click", function(e) { // "mouseover" and "mouseout" events not used here
if (e.data) {
Promise.all([
ffetch(inat_urlbase+'observations/'+e.data.id),
Promise.resolve(e.data.cellCount)
])
.then ((data) => { fpopup(data[0].results[0],data[1]); });
};
});
var u_inat_grid_all = L.utfGrid(inat_urlbase+'grid/{z}/{x}/{y}.grid.json?'+winurlparams, u_inat_options);
u_inat_grid_all.on("click", function(e) { // "mouseover" and "mouseout" events not used here
if (e.data) {
Promise.all([
ffetch(inat_urlbase+'observations/'+e.data.id),
Promise.resolve(e.data.cellCount)
])
.then ((data) => { fpopup(data[0].results[0],data[1]); });
};
});
var u_inat_grid_superset = L.utfGrid(inat_urlbase+'grid/{z}/{x}/{y}.grid.json?'+compareurlparams, u_inat_options);
u_inat_grid_superset.on("click", function(e) { // "mouseover" and "mouseout" events not used here
if (e.data) {
Promise.all([
ffetch(inat_urlbase+'observations/'+e.data.id),
Promise.resolve(e.data.cellCount)
])
.then ((data) => { fpopup(data[0].results[0],data[1]); });
};
});
var v_inat_options = {
idField: 'id', // Expects UTFgrid to have a property 'ID' that indicates the feature ID
buildIndex: true, // requires above field to be set properly
fillColor: 'black',
shadowBlur: 0, // Number of pixels for blur effect
shadowColor: null, // Color for shadow, if present. Defaults to fillColor.
debug: false, // if true, show tile borders and tile keys
minZoom:0,
maxZoom:20,
};
var v_inat_points = L.utfGridCanvas(inat_urlbase+'points/{z}/{x}/{y}.grid.json?'+winurlparams, { ...v_inat_options, minZoom:10, });
var v_inat_points_all = L.utfGridCanvas(inat_urlbase+'points/{z}/{x}/{y}.grid.json?'+winurlparams, v_inat_options);
var v_inat_grid = L.utfGridCanvas(inat_urlbase+'grid/{z}/{x}/{y}.grid.json?'+winurlparams, { ...v_inat_options, minZoom:2, maxZoom:9 });
var v_inat_grid_all = L.utfGridCanvas(inat_urlbase+'grid/{z}/{x}/{y}.grid.json?'+winurlparams, v_inat_options);
var v_inat_grid_superset = L.utfGridCanvas(inat_urlbase+'grid/{z}/{x}/{y}.grid.json?'+compareurlparams, v_inat_options);