File tree Expand file tree Collapse file tree 1 file changed +33
-18
lines changed Expand file tree Collapse file tree 1 file changed +33
-18
lines changed Original file line number Diff line number Diff line change 1- import { geoPath } from "d3" ;
2-
31export const Basemap = ( {
4- geoJSONFeatures ,
5- pathGenerator ,
6- height = 975 ,
7- width = 610 ,
8- pathProps ,
2+ geoJSON ,
3+ height = 610 ,
4+ pathGen ,
5+ pathProps = { } ,
6+ width = 975 ,
97} ) => {
10- const fill = props . fill || "none" ;
11- const stroke = props . stroke || "white" ;
8+ geoJSON && console . log ( "geoJSON:\n" , geoJSON ) ;
9+
10+ const isMultiLineString = geoJSON . type === "MultiLineString" ;
1211
1312 return (
14- < svg viewbox = { `0 0 ${ width } ${ height } ` } xmlns = "http://www.w3.org/2000/svg" >
13+ < svg viewBox = { `0 0 ${ width } ${ height } ` } xmlns = "http://www.w3.org/2000/svg" >
1514 < g >
16- { geoJSONFeatures . map ( ( { id, geometry } ) => {
17- < path
18- key = { id }
19- d = { pathGenerator ( geometry ) }
20- fill = { fill }
21- stroke = { stroke }
22- /> ;
23- } ) }
15+ { isMultiLineString
16+ ? geoJSON . coordinates . map ( ( array , index ) => {
17+ return (
18+ < path
19+ key = { index }
20+ d = { pathGen ( {
21+ type : "LineString" ,
22+ coordinates : array ,
23+ } ) }
24+ { ...pathProps }
25+ className = "hover:fill-green-400"
26+ />
27+ ) ;
28+ } )
29+ : geoJSON . features . map ( ( { id, geometry } ) => {
30+ return (
31+ < path
32+ key = { id }
33+ d = { pathGen ( geometry ) }
34+ { ...pathProps }
35+ className = "hover:fill-green-400"
36+ />
37+ ) ;
38+ } ) }
2439 </ g >
2540 </ svg >
2641 ) ;
You can’t perform that action at this time.
0 commit comments