* Render MultiPolygon to SVG
(multipolygon)
| 374 | * Render MultiPolygon to SVG |
| 375 | */ |
| 376 | multiPolygonToSVG(multipolygon) { |
| 377 | const shapeArrays = multipolygon.coords.map((shape) => shape.map((coord) => [ |
| 378 | this.xToPx(geoutils.lonToX(coord[0], this.zoom)), |
| 379 | this.yToPx(geoutils.latToY(coord[1], this.zoom)), |
| 380 | ])); |
| 381 | |
| 382 | const pathArrays = shapeArrays.map((points) => { |
| 383 | const startPoint = points.shift(); |
| 384 | |
| 385 | const pathParts = [ |
| 386 | `M ${startPoint[0]} ${startPoint[1]}`, |
| 387 | ...points.map((p) => `L ${p[0]} ${p[1]}`), |
| 388 | 'Z', |
| 389 | ]; |
| 390 | |
| 391 | return pathParts.join(' '); |
| 392 | }); |
| 393 | |
| 394 | return `<path |
| 395 | d="${pathArrays.join(' ')}" |
| 396 | style="fill-rule: inherit;" |
| 397 | stroke="${multipolygon.color}" |
| 398 | fill="${multipolygon.fill ? multipolygon.fill : 'none'}" |
| 399 | stroke-width="${multipolygon.width}"/>`; |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * Render Polyline to SVG |
no test coverage detected