Created
August 14, 2021 08:45
-
-
Save furandon-pig/bf7105e045de0b3c57c3900ae4f12159 to your computer and use it in GitHub Desktop.
code4fukui.github.io/csv-map/csv-map.jsのL.marker()をL.polygon()にするサンプルです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- csv-map.js.ORIG 2021-08-14 17:39:28.172959000 +0900 | |
+++ csv-map.js 2021-08-14 17:40:28.675902000 +0900 | |
@@ -156,8 +156,6 @@ | |
} | |
} | |
- const marker = L.marker(ll, opt); | |
- | |
const d2 = (() => { | |
if (!filter) { | |
return d; | |
@@ -171,7 +169,36 @@ | |
return res; | |
})(); | |
const tbl = makeTable(d2); | |
+ | |
+ let a1 = d2['河川水位']; | |
+ let a2 = d2['はん濫危険水位']; | |
+ | |
+ if (String(a1).match(/^[\.0-9]*$/) == null) { | |
+ a1 = 0.01; | |
+ } | |
+ if (String(a2).match(/^[\.0-9]*$/) == null) { | |
+ a2 = a1; | |
+ } | |
+ | |
+ const rate = 0.01 * (a1 / a2); | |
+ const marker = L.polygon([ | |
+ [ll[0] + 0.01, ll[1] - 0.01], | |
+ [ll[0] + 0.01, ll[1] + 0.01], | |
+ [ll[0], ll[1] + 0.01], | |
+ [ll[0], ll[1] - 0.01], | |
+ ], {}); | |
+ const marker2 = L.polygon([ | |
+ [ll[0] + rate, ll[1] - 0.01], | |
+ [ll[0] + rate, ll[1] + 0.01], | |
+ [ll[0], ll[1] + 0.01], | |
+ [ll[0], ll[1] - 0.01], | |
+ ], { | |
+ color: 'red', | |
+ fillColor: 'red' | |
+ }); | |
+ | |
marker.bindPopup((title ? (url ? `<a href=${url}>${title}</a>` : title) : "") + tbl); | |
+ this.iconlayer.addLayer(marker2); | |
this.iconlayer.addLayer(marker); | |
lls.push(ll); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment