Skip to content

Instantly share code, notes, and snippets.

@himloul
Created February 10, 2021 19:30
Show Gist options
  • Save himloul/7389f50424c4d0bc481cf3b79a6143d0 to your computer and use it in GitHub Desktop.
Save himloul/7389f50424c4d0bc481cf3b79a6143d0 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>leaflet</title>
<script src="data:application/javascript;base64,KGZ1bmN0aW9uKCkgewogIC8vIElmIHdpbmRvdy5IVE1MV2lkZ2V0cyBpcyBhbHJlYWR5IGRlZmluZWQsIHRoZW4gdXNlIGl0OyBvdGhlcndpc2UgY3JlYXRlIGEKICAvLyBuZXcgb2JqZWN0LiBUaGlzIGFsbG93cyBwcmVjZWRpbmcgY29kZSB0byBzZXQgb3B0aW9ucyB0aGF0IGFmZmVjdCB0aGUKICAvLyBpbml0aWFsaXphdGlvbiBwcm9jZXNzICh0aG91Z2ggbm9uZSBjdXJyZW50bHkgZXhpc3QpLgogIHdpbmRvdy5IVE1MV2lkZ2V0cyA9IHdpbmRvdy5IVE1MV2lkZ2V0cyB8fCB7fTsKCiAgLy8gU2VlIGlmIHdlJ3JlIHJ1bm5pbmcgaW4gYSB2aWV3ZXIgcGFuZS4gSWYgbm90LCB3ZSdyZSBpbiBhIHdlYiBicm93c2VyLgogIHZhciB2aWV3ZXJNb2RlID0gd2luZG93LkhUTUxXaWRnZXRzLnZpZXdlck1vZGUgPQogICAgICAvXGJ2aWV3ZXJfcGFuZT0xXGIvLnRlc3Qod2luZG93LmxvY2F0aW9uKTsKCiAgLy8gU2VlIGlmIHdlJ3JlIHJ1bm5pbmcgaW4gU2hpbnkgbW9kZS4gSWYgbm90LCBpdCdzIGEgc3RhdGljIGRvY3VtZW50LgogIC8vIE5vdGUgdGhhdCBzdGF0aWMgd2lkZ2V0cyBjYW4gYXBwZWFyIGluIGJvdGggU2hpbnkgYW5kIHN0YXRpYyBtb2RlcywgYnV0CiAgLy8gb2J2aW91c2x5LCBTaGlueSB3aWRnZXRzI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ZhciBlcnJDbGFzcyA9ICJzaGlueS1vdXRwdXQtZXJyb3IiOwogICAgICBpZiAoZXJyLnR5cGUgIT09IG51bGwpIHsKICAgICAgICAvLyB1c2UgdGhlIGNsYXNzZXMgb2YgdGhlIGVycm9yIGNvbmRpdGlvbiBhcyBDU1MgY2xhc3MgbmFtZXMKICAgICAgICBlcnJDbGFzcyA9IGVyckNsYXNzICsgIiAiICsgJC5tYXAoYXNBcnJheShlcnIudHlwZSksIGZ1bmN0aW9uKHR5cGUpIHsKICAgICAgICAgIHJldHVybiBlcnJDbGFzcyArICItIiArIHR5cGU7CiAgICAgICAgfSkuam9pbigiICIpOwogICAgICB9CiAgICAgIGVyckNsYXNzID0gZXJyQ2xhc3MgKyAiIGh0bWx3aWRnZXRzLWVycm9yIjsKCiAgICAgIC8vIElzIGVsIGlubGluZSBvciBibG9jaz8gSWYgaW5saW5lIG9yIGlubGluZS1ibG9jaywganVzdCBkaXNwbGF5Om5vbmUgaXQKICAgICAgLy8gYW5kIGFkZCBhbiBpbmxpbmUgZXJyb3IuCiAgICAgIHZhciBkaXNwbGF5ID0gJGVsLmNzcygiZGlzcGxheSIpOwogICAgICAkZWwuZGF0YSgicmVzdG9yZS1kaXNwbGF5LW1vZGUiLCBkaXNwbGF5KTsKCiAgICAgIGlmIChkaXNwbGF5ID09PSAiaW5saW5lIiB8fCBkaXNwbGF5ID09PSAiaW5saW5lLWJsb2NrIikgewogICAgICAgICRlbC5oaWRlKCk7CiAgICAgICAgaWYgKGVyci5tZXNzYWdlICE9PSAiIikgewogICAgICAgICAgdmFyIGVycm9yU3BhbiA9ICQoIjxzcGFuPiIpLmFkZENsYXNzKGVyckNsYXNzKTsKICAgICAgICAgIGVycm9yU3Bhbi50ZXh0KGVyci5tZXNzYWdlKTsKICAgICAgICAgICRlbC5hZnRlcihlcnJvclNwYW4pOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChkaXNwbGF5ID09PSAiYmxvY2siKSB7CiAgICAgICAgLy8gS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gICAgIC8vIFJlYWxseSBkdW1iIHdheSB0byBrZWVwIHRoZSBzaXplL3Bvc2l0aW9uIG9mIHRoZSBlcnJvciBpbiBzeW5jIHdpdGgKICAgICAgICAgIC8vIHRoZSBwYXJlbnQgZWxlbWVudCBhcyB0aGUgd2luZG93IGlzIHJlc2l6ZWQgb3Igd2hhdGV2ZXIuCiAgICAgICAgICB2YXIgaW50SWQgPSBzZXRJbnRlcnZhbChmdW5jdGlvbigpIHsKICAgICAgICAgICAgaWYgKCFlcnJvckRpdlswXS5wYXJlbnRFbGVtZW50KSB7CiAgICAgICAgICAgICAgY2xlYXJJbnRlcnZhbChpbnRJZCk7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yRGl2CiAgICAgICAgICAgICAgLmNzcygidG9wIiwgZWwub2Zmc2V0VG9wKQogICAgICAgICAgICAgIC5jc3MoImxlZnQiLCBlbC5vZmZzZXRMZWZ0KQogICAgICAgICAgICAgIC5jc3MoIm1heFdpZHRoIiwgZWwub2Zmc2V0V2lkdGgpCiAgICAgICAgICAgICAgLmNzcygiaGVpZ2h0IiwgZWwub2Zmc2V0SGVpZ2h0KTsKICAgICAgICAgIH0sIDUwMCk7CiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgY2xlYXJFcnJvcjogZnVuY3Rpb24oZWwpIHsKICAgICAgdmFyICRlbCA9ICQoZWwpOwogICAgICB2YXIgZGlzcGxheSA9ICRlbC5kYXRhKCJyZXN0b3JlLWRpc3BsYXktbW9kZSIpOwogICAgICAkZWwuZGF0YSgicmVzdG9yZS1kaXNwbGF5LW1vZGUiLCBudWxsKTsKCiAgICAgIGlmIChkaXNwbGF5ID09PSAiaW5saW5lIiB8fCBkaXNwbGF5ID09PSAiaW5saW5lLWJsb2NrIikgewogICAgICAgIGlmIChkaXNwbGF5KQogICAgICAgICAgJGVsLmNzcygiZGlzcGxheSIsIGRpc3BsYXkpOwogICAgICAgICQoZWwubmV4dFN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KICAgICAgICB9CiAgICAgICAgaWYgKCFiaW5kaW5nRGVmLnJlbmRlck9uTnVsbFZhbHVlKSB7CiAgICAgICAgICBpZiAoZGF0YS54ID09PSBudWxsKSB7CiAgICAgICAgICAgIGVsLnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZWwuc3R5bGUudmlzaWJpbGl0eSA9ICJpbmhlcml0IjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKCFlbGVtZW50RGF0YShlbCwgImluaXRpYWxpemVkIikpIHsKICAgICAgICAgIGluaXRTaXppbmcoZWwpOwoKICAgICAgICAgIGVsZW1lbnREYXRhKGVsLCAiaW5pdGlhbGl6ZWQiLCB0cnVlKTsKICAgICAgICAgIGlmIChiaW5kaW5nRGVmLmluaXRpYWxpemUpIHsKICAgICAgICAgICAgdmFyIHJlc3VsdCA9IGJpbmRpbmdEZWYuaW5pdGlhbGl6ZShlbCwgZWwub2Zmc2V0V2lkdGgsCiAgICAgICAgICAgICAgZWwub2Zmc2V0SGVpZ2h0KTsKICAgICAgICAgICAgZWxlbWVudERhdGEoZWwsICJpbml0X3Jlc3VsdCIsIHJlc3VsdCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGJpbmRpbmdEZWYucmVuZGVyVmFsdWUoZWwsIGRhdGEueCwgZWxlbWVudERhdGEoZWwsICJpbml0X3Jlc3VsdCIpKTsKICAgICAgICBldmFsQW5kUnVuKGRhdGEuanNIb29rcy5yZW5kZXIsIGVsZW1lbnREYXRhKGVsLCAiaW5pdF9yZXN1bHQiKSwgW2VsLCBkYXRhLnhdKTsKICAgICAgfTsKCiAgICAgIC8vIE9ubHkgb3ZlcnJpZGUgcmVzaXplIGlmIGJpbmRpbmdEZWYgaW1wbGVtZW50cyBpdAogICAgICBpZiAoYmluZGluZ0RlZi5yZXNpemUpIHsKICAgICAgICBzaGl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V0V2lkdGgoKSA6IGVsLm9mZnNldFdpZHRoLAogICAgICAgICAgICBoOiBzaXplT2JqID8gc2l6ZU9iai5nZXRIZWlnaHQoKSA6IGVsLm9mZnNldEhlaWdodAogICAgICAgICAgfTsKICAgICAgICAgIHZhciByZXNpemVIYW5kbGVyID0gZnVuY3Rpb24oZSkgewogICAgICAgICAgICB2YXIgc2l6ZSA9IHsKICAgICAgICAgICAgICB3OiBzaXplT2JqID8gc2l6ZU9iai5nZXRXaWR0aCgpIDogZWwub2Zmc2V0V2lkdGgsCiAgICAgICAgICAgICAgaDogc2l6ZU9iaiA/IHNpemVPYmouZ2V0SGVpZ2h0KCkgOiBlbC5vZmZzZXRIZWlnaHQKICAgICAgICAgICAgfTsKICAgICAgICAgICAgaWYgKHNpemUudyA9PT0gMCAmJiBzaXplLmggPT09IDApCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoc2l6ZS53ID09PSBsYXN0U2l6ZS53ICYmIHNpemUuaCA9PT0gbGFzdFNpemUuaCkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIGxhc3RTaXplID0gc2l6ZTsKICAgICAgICAgICAgYmluZGluZy5yZXNpemUoZWwsIHNpemUudywgc2l6ZS5oLCBpbml0UmVzdWx0KTsKICAgICAgICAgIH07CgogICAgICAgICAgb24od2luZG93LCAicmVzaXplIiwgcmVzaXplSGFuZGxlcik7CgogICAgICAgICAgLy8gVGhpcyBpcyBuZWVkZWQgZm9yIGNhc2VzIHdoZXJlIHdlJ3JlIHJ1bm5pbmcgaW4gYSBTaGlueQogICAgICAgICAgLy8gYXBwLCBidXQgdGhlIHdpZGdldCBpdHNlbGYgaXMgbm90IGEgU2hpbnkgb3V0cHV0LCBidXQKICAgICAgICAgIC8vIHJhdGhlciBhIHNpbXBsZSBzdGF0aWMgd2lkZ2V0LiBPbmUgZXhhbXBsZSBvZiB0aGlzIGlzCiAgICAgICAgICAvLyBhbiBybWFya2Rvd24gZG9jdW1lbn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WdodCk7CiAgICAgIH0sCiAgICAgIHJlbmRlclZhbHVlOiBmdW5jdGlvbihlbCwgeCwgaW5zdGFuY2UpIHsKICAgICAgICByZXR1cm4gaW5zdGFuY2UucmVuZGVyVmFsdWUoeCk7CiAgICAgIH0sCiAgICAgIHJlc2l6ZTogZnVuY3Rpb24oZWwsIHdpZHRoLCBoZWlnaHQsIGluc3RhbmNlKSB7CiAgICAgICAgcmV0dXJuIGluc3RhbmNlLnJlc2l6ZSh3aWR0aCwgaGVpZ2h0KTsKICAgICAgfQogICAgfTsKCiAgICBpZiAoZGVmbi5maW5kKQogICAgICByZXN1bHQuZmluZCA9IGRlZm4uZmluZDsKICAgIGlmIChkZWZuLnJlbmRlckVycm9yKQogICAgICByZXN1bHQucmVuZGVyRXJyb3IgPSBkZWZuLnJlbmRlckVycm9yOwogICAgaWYgKGRlZm4uY2xlYXJFcnJvcikKICAgICAgcmVzdWx0LmNsZWFyRXJyb3IgPSBkZWZuLmNsZWFyRXJyb3I7CgogICAgcmV0dXJuIHJlc3VsdDsKICB9Cn0pKCk7Cgo="></script>
<script src="data:application/javascript;base64,LyohIGpRdWVyeSB2MS4xMi40IHwgKGMpIGpRdWVyeSBGb3VuZGF0aW9uIHwganF1ZXJ5Lm9yZy9saWNlbnNlICovCiFmdW5jdGlvbihhLGIpeyJvYmplY3QiPT10eXBlb2YgbW9kdWxlJiYib2JqZWN0Ij09dHlwZW9mIG1vZHVsZS5leHBvcnRzP21vZHVsZS5leHBvcnRzPWEuZG9jdW1lbnQ/YihhLCEwKTpmdW5jdGlvbihhKXtpZighYS5kb2N1bWVudCl0aHJvdyBuZXcgRXJyb3IoImpRdWVyeSByZXF1aXJlcyBhIHdpbmRvdyB3aXRoIGEgZG9jdW1lbnQiKTtyZXR1cm4gYihhKX06YihhKX0oInVuZGVmaW5lZCIhPXR5cGVvZiB3aW5kb3c/d2luZG93OnRoaXMsZnVuY3Rpb24oYSxiKXt2YXIgYz1bXSxkPWEuZG9jdW1lbnQs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cCgpKWlmKChoP20ubm9kZU5hbWUudG9Mb3dlckNhc2UoKT09PXI6MT09PW0ubm9kZVR5cGUpJiYrK3QmJihzJiYobD1tW3VdfHwobVt1XT17fSksaz1sW20udW5pcXVlSURdfHwobFttLnVuaXF1ZUlEXT17fSksa1thXT1bdyx0XSksbT09PWIpKWJyZWFrO3JldHVybiB0LT1lLHQ9PT1kfHx0JWQ9PT0wJiZ0L2Q+PTB9fX0sUFNFVURPOmZ1bmN0aW9uKGEs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment