{"id":3696,"date":"2014-08-18T10:40:27","date_gmt":"2014-08-18T01:40:27","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=3696"},"modified":"2014-08-20T21:29:14","modified_gmt":"2014-08-20T12:29:14","slug":"post-3696","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/leaflet-js\/3696","title":{"rendered":"[leaflet]\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u3067\u306e\u753b\u50cf\u51e6\u7406\u3092\u53ef\u80fd\u306b\u3059\u308b\u300ctilefilter\u300d\u30d7\u30e9\u30b0\u30a4\u30f3"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/humangeo\/leaflet-tilefilter\/wiki\">Home \u00b7 humangeo\/leaflet-tilefilter Wiki<\/a><\/p>\n<p>\u300ctilefilter\u300d\u30d7\u30e9\u30b0\u30a4\u30f3\u306f\u3001leaflet\u306b\u3066\u8aad\u307f\u8fbc\u3093\u3060\u30bf\u30a4\u30eb\u753b\u50cf\u3092\u30d6\u30e9\u30a6\u30b6\u306b\u63cf\u753b\u3055\u308c\u308b\u524d\u306b\u30d5\u30c3\u30af\u3057\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u306b\u3066\u753b\u50cf\u51e6\u7406\u304c\u884c\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002<br \/>\n\u3053\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u306f\u300cCanvas\u30d5\u30a3\u30eb\u30bf\u30fc\u300d\u3068\u300cCSS\u30d5\u30a3\u30eb\u30bf\u30fc\u300d\u306e\u4e8c\u7a2e\u985e\u306e\u65b9\u6cd5\u3067\u753b\u50cf\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>leaflet.js\u8aad\u307f\u8fbc\u307f\u5f8c\u306bTileLayer.Filter.js\u3092\u8aad\u307f\u8fbc\u3093\u3067\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"lang:xhtml decode:true \" >&lt;script src=\"leaflet.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"TileLayer.Filter.js\"&gt;&lt;\/script&gt;<\/pre>\n<h2>canvas\u30d5\u30a3\u30eb\u30bf\u30fc<\/h2>\n<p>\u30bf\u30a4\u30eb\u753b\u50cf\u3092\u3044\u3063\u305f\u3093canvas\u3078\u3068\u8ee2\u5199\u3057\u3001Image Processing\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var hogeLayer = new L.TileLayer('http:\/\/cyberjapandata.gsi.go.jp\/xyz\/pale\/{z}\/{x}\/{y}.png', {\r\n\tattribution: '\u5730\u7406\u9662\u30bf\u30a4\u30eb',\r\n    filter: function () {\r\n            new L.CanvasFilter(this, {\r\n                channelFilter: function (imageData) {\r\n\t\t\t\t\r\n\t\t\t\t\t\/\/ \u753b\u50cf\u51e6\u7406\u3092\u884c\u3046\r\n\t\t\t\t\r\n\t\t\t\t\treturn imageData;\r\n                }\r\n            }).render();\r\n    }\r\n});<\/pre>\n<p>channelFilter\u306e\u5f15\u6570\u306b\u3001\u30bf\u30a4\u30eb\u753b\u50cf\u3092canvas\u306b\u8ee2\u5199\u3057\u305f\u969b\u306eImageData Object\u304c\u9001\u3089\u308c\u307e\u3059\u3002<br \/>\n\u3053\u306eImageData Object\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u3067\u69d8\u3005\u306a\u30d5\u30a3\u30eb\u30bf\u52b9\u679c\u3092\u4ed8\u52a0\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/gunmagisgeek.com\/blog\/leaflet-js\/3693\">\u524d\u56de\u306e\u8a18\u4e8b<\/a>\u3067\u306f\u3001\u5730\u7406\u9662\u30bf\u30a4\u30eb\uff08\u96fb\u5b50\u56fd\u571f\u57fa\u672c\u56f3\uff09\u3092\u8aad\u307f\u8fbc\u307f\u3001\u30a8\u30c3\u30b8\u3092\u62bd\u51fa\u3057\u30a8\u30c3\u30b8(\u767d\u8272)\u4ee5\u5916\u306e\u900f\u660e\u5ea6\u30920\u306b\u3057\u3066\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"height-set:true lang:js decode:true \" title=\"edgeLayer \" >var edgeLayer = new L.TileLayer('http:\/\/cyberjapandata.gsi.go.jp\/xyz\/pale\/{z}\/{x}\/{y}.png', {\r\n\tattribution: '\u5730\u7406\u9662\u30bf\u30a4\u30eb\uff08\u6a19\u6e96\u5730\u56f3\u30a8\u30c3\u30b8\uff09',\r\n    filter: function () {\r\n            new L.CanvasFilter(this, {\r\n                channelFilter: function (imageData) {\r\n\t\t\t\t\tedge(imageData.data);\r\n\t\t\t\t\treturn imageData;\r\n                }\r\n            }).render();\r\n    }\r\n});\r\n\r\n\r\nfunction edge(data) {\r\n    var length = data.length;\r\n    var width = 256, height = 256;\r\n    var gray = new Uint8ClampedArray(data.length);\r\n    toGray(data, gray);\r\n    var edge = new Uint8ClampedArray(data.length);\r\n    \r\n    for (var y = 0; y &lt; height - 1; y++) {\r\n        for (var x = 0; x &lt; width - 1; x++) {\r\n            var i = x + y * width;     \r\n            var r_i = (x + 1) + y * width; \r\n            var ex = gray[r_i] - gray[i];\r\n            \r\n            var d_i = x + (y + 1) * width;\r\n            var ey = gray[d_i] - gray[i]; \r\n            \r\n            var ez = Math.sqrt(ex * ex + ey * ey);\r\n            edge[i] = ez * 2; \r\n        }\r\n    }\r\n    toColor(edge, data);\r\n \r\n}\r\n \r\nfunction toGray(rgba, gray) {\r\n    var length = rgba.length;\r\n    var total = 0; \r\n    for (var i = 0; i &lt; length; i += 4) {\r\n        var g = 0.30 * rgba[i + 0] + 0.59 * rgba[i + 1] + 0.11 * rgba[i + 2];\r\n        gray[i\/4] = g;\r\n        total += g;\r\n    }\r\n    return total \/ (length \/ 4);\r\n}\r\n \r\nfunction toColor(gray, rgba) {\r\n    var length = gray.length * 4;\r\n    for (var i = 0; i &lt; length; i += 4) {\r\n        rgba[i + 0] = gray[i\/4];\r\n        rgba[i + 1] = gray[i\/4];\r\n        rgba[i + 2] = gray[i\/4];\r\n\t\tif (gray[i\/4] &gt; 180){ \t\r\n\t        rgba[i + 3] = 255;\r\n\t\t}else{\r\n\t        rgba[i + 3] = 0;\t\t\t\r\n\t\t}\r\n    }\r\n}<\/pre>\n<h3>\u30d3\u30eb\u30c8\u30a4\u30f3\u30d5\u30a3\u30eb\u30bf\u30fc<\/h3>\n<p>canvas\u30d5\u30a3\u30eb\u30bf\u30fc\u306b\u306f\u3001\u3044\u304f\u3064\u304b\u306e\u7d44\u307f\u8fbc\u307f\u30d5\u30a3\u30eb\u30bf\u30fc\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306f\u3001\u30bb\u30d4\u30a2\u52b9\u679c\u3092\u4ed8\u52a0\u3059\u308b\u30d5\u30a3\u30eb\u30bf\u30fc<\/p>\n<pre class=\"lang:js decode:true \" title=\"Sepia Filter\" >var baseLayer = new L.TileLayer('http:\/\/otile1.mqcdn.com\/tiles\/1.0.0\/map\/{z}\/{x}\/{y}.jpg', {\r\n    filter: function () {\r\n            new L.CanvasFilter(this, {\r\n                channelFilter: function (imageData) {\r\n                    return new L.CanvasChannelFilters.Sepia(imageData).render();\r\n                }\r\n            }).render();\r\n    }\r\n});<\/pre>\n<h2>CSS\u30d5\u30a3\u30eb\u30bf\u30fc<\/h2>\n<p>\u30d6\u30e9\u30a6\u30b6\u306eCSS\u30d5\u30a3\u30eb\u30bf\u30fc\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u30bf\u30a4\u30eb\u753b\u50cf\u306b\u30d5\u30a3\u30eb\u30bf\u30fc\u52b9\u679c\u3092\u4ed8\u52a0\u3057\u307e\u3059\u3002Chrome\u306a\u3069\u30d6\u30e9\u30a6\u30b6\u3067\u306f\u3001CSS\u3067\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u52b9\u679c\u304cGPU\u306b\u3088\u3063\u3066\u30a2\u30af\u30bb\u30e9\u30ec\u30fc\u30b7\u30e7\u30f3\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u308b\u305f\u3081\u3001\u5358\u7d14\u306a\u753b\u50cf\u51e6\u7406\u3067\u3042\u308c\u3070canvas\u3067ImageData\u3092\u5f04\u308b\u3088\u308a\u9ad8\u901f\u306b\u63cf\u753b\u3055\u308c\u307e\u3059\u3002<br \/>\n\u203bWebkit\u7cfb\u30d6\u30e9\u30a6\u30b6\u4ee5\u5916\u3067\u306fCSS Filter\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u304c\u591a\u6570\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var ort = new L.TileLayer('http:\/\/cyberjapandata.gsi.go.jp\/xyz\/ort\/{z}\/{x}\/{y}.jpg', {\r\n\tattribution: '\u5730\u7406\u9662\u30bf\u30a4\u30eb\uff08\u30aa\u30eb\u30bd\u753b\u50cf\uff09',\r\n\tfilter:function () {\r\n        new L.CSSFilter(this, {\r\n            filters: \/\/css\u30d5\u30a3\u30eb\u30bf\u30fc\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6307\u5b9a\r\n        }).render();\r\n    }\r\n});<\/pre>\n<h3>\u30b5\u30f3\u30d7\u30eb<\/h3>\n<p>\u4e0b\u8a18\u306fcss\u30d5\u30a3\u30eb\u30bf\u30fc\u306e\u300cinvert\u300d\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3063\u3066\u30bf\u30a4\u30eb\u753b\u50cf\u306b\u5bfe\u3057\u3066\u968e\u8abf\u306e\u53cd\u8ee2\u3092\u884c\u3063\u305f\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/shimz.me\/example\/leaflet\/filter\/cssFilter\/01\/index.html\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/08\/leafletcssfiter140818.jpg\" alt=\"leaflet css fiter\" width=\"590\" height=\"338\" class=\"aligncenter size-full wp-image-3697\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/08\/leafletcssfiter140818.jpg 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/08\/leafletcssfiter140818-262x150.jpg 262w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/shimz.me\/example\/leaflet\/filter\/cssFilter\/01\/index.html\">example<\/a><\/p>\n<pre class=\"lang:js decode:true \" title=\"css filter sample\" >var ort = new L.TileLayer('http:\/\/cyberjapandata.gsi.go.jp\/xyz\/ort\/{z}\/{x}\/{y}.jpg', {\r\n\tattribution: '\u5730\u7406\u9662\u30bf\u30a4\u30eb\uff08\u30aa\u30eb\u30bd\u753b\u50cf\uff09',\r\n\tfilter:function () {\r\n        new L.CSSFilter(this, {\r\n            filters:['invert(100%)']\r\n        }).render();\r\n    }\r\n});<\/pre>\n<p>css\u30d5\u30a3\u30eb\u30bf\u30fc\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u8907\u6570\u6307\u5b9a\u53ef\u80fd\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Home \u00b7 humangeo\/leaflet-t&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3697,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[],"class_list":["post-3696","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-leaflet-js","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=3696"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3696\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/3697"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=3696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=3696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=3696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}