-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#25: add suport for MultiPolygons in search results
- Loading branch information
1 parent
78b094b
commit 27e42e8
Showing
4 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { Polygon as LeafletPolygon } from 'react-leaflet'; | ||
|
||
export default function MultiPolygon({ searchResult, theme }) { | ||
|
||
let polygonsLatLons = []; | ||
searchResult.geojson.coordinates.forEach( polygonCoords => { | ||
const polygonLatLons = polygonCoords[0].map(lonlat => { | ||
return L.latLng(lonlat[1], lonlat[0]); | ||
}); | ||
polygonsLatLons.push(polygonLatLons); | ||
}); | ||
|
||
let leafletOptions = { fillColor: 'grey', color: 'grey' }; | ||
if (theme == 'selected') { | ||
leafletOptions = { fillColor: 'green', color: 'green' }; | ||
} | ||
return ( | ||
<div> | ||
{ | ||
polygonsLatLons.map(p => { | ||
return <LeafletPolygon positions={p} {...leafletOptions} />; | ||
}) | ||
} | ||
</div> | ||
|
||
); | ||
} | ||
|
||
MultiPolygon.propTypes = { | ||
searchResult: React.PropTypes.any, | ||
theme: React.PropTypes.oneOf([ 'selected', 'highlighted' ]) | ||
}; |
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