| 40 | } |
| 41 | |
| 42 | function drawMap(static_container, mode) { |
| 43 | const static_ctx = static_container.getContext("2d"); |
| 44 | static_ctx.clearRect(0, 0, static_container.width, static_container.height); |
| 45 | |
| 46 | projection = d3.geoNaturalEarth1() |
| 47 | .fitSize([width, height], cachedData) |
| 48 | |
| 49 | shanghai_projected = projection(shanghai); |
| 50 | |
| 51 | const path = d3.geoPath() |
| 52 | .projection(projection) |
| 53 | .context(static_ctx); |
| 54 | |
| 55 | static_ctx.fillStyle = color[mode].country_fill; |
| 56 | static_ctx.strokeStyle = color[mode].country_border; |
| 57 | |
| 58 | static_ctx.globalAlpha = 1.0; |
| 59 | static_ctx.filter = "none"; |
| 60 | cachedData.features.forEach(feature => { |
| 61 | static_ctx.beginPath(); |
| 62 | path(feature); |
| 63 | static_ctx.fill(); |
| 64 | static_ctx.stroke(); |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Based on snap.svg bezlen() function |