-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from performant-software/feature/cdc248_geore…
…ference_layers CDC #248 - Geo-reference layers
- Loading branch information
Showing
22 changed files
with
630 additions
and
67 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
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
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,72 @@ | ||
// @flow | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { useMap } from 'react-map-gl'; | ||
import MapUtils from '../utils/Map'; | ||
|
||
type Props = { | ||
/** | ||
* ID of the new layer. | ||
*/ | ||
id: string, | ||
|
||
/** | ||
* (Optional) IIIF manifest content containing the image and geo-reference annotations. | ||
*/ | ||
manifest?: string, | ||
|
||
/** | ||
* (Optional) layer opacity. | ||
*/ | ||
opacity?: number, | ||
|
||
/** | ||
* (Optional) URL to the IIIF manifest. | ||
*/ | ||
url?: string | ||
}; | ||
|
||
const WarpedImageLayer = (props: Props) => { | ||
const [loaded, setLoaded] = useState(false); | ||
|
||
const mapRef = useMap(); | ||
|
||
/** | ||
* Sets the "loaded" attribute on the state based on the current map state. | ||
*/ | ||
useEffect(() => { | ||
const instance = mapRef?.current?.getMap(); | ||
if (instance && instance.loaded()) { | ||
setLoaded(true); | ||
} else if (instance) { | ||
instance.on('load', () => setLoaded(true)); | ||
} | ||
}, []); | ||
|
||
/** | ||
* Adds the WarpedMapLayer object to the map as a new layer. | ||
*/ | ||
useEffect(() => { | ||
if (!loaded) { | ||
return undefined; | ||
} | ||
|
||
const map = mapRef.current.getMap(); | ||
|
||
MapUtils.addGeoreferenceLayer(map, props.id, { | ||
manifest: props.manifest, | ||
opacity: props.opacity, | ||
url: props.url | ||
}); | ||
|
||
return () => MapUtils.removeLayer(map, props.id); | ||
}, [loaded]); | ||
|
||
return null; | ||
}; | ||
|
||
WarpedImageLayer.defaultProps = { | ||
opacity: 0.5 | ||
}; | ||
|
||
export default WarpedImageLayer; |
56 changes: 56 additions & 0 deletions
56
packages/geospatial/src/components/WarpedImageLayerPeripleo.js
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,56 @@ | ||
// @flow | ||
|
||
import { useEffect } from 'react'; | ||
import { useLoadedMap } from '@peripleo/maplibre'; | ||
import MapUtils from '../utils/Map'; | ||
|
||
type Props = { | ||
/** | ||
* ID of the new layer. | ||
*/ | ||
id: string, | ||
|
||
/** | ||
* (Optional) IIIF manifest content containing the image and geo-reference annotations. | ||
*/ | ||
manifest?: string, | ||
|
||
/** | ||
* (Optional) layer opacity. | ||
*/ | ||
opacity?: number, | ||
|
||
/** | ||
* (Optional) URL to the IIIF manifest. | ||
*/ | ||
url?: string | ||
}; | ||
|
||
const WarpedImageLayer = (props: Props) => { | ||
const map = useLoadedMap(); | ||
|
||
/** | ||
* Adds the WarpedMapLayer object to the map as a new layer. | ||
*/ | ||
useEffect(() => { | ||
if (!map) { | ||
return undefined; | ||
} | ||
|
||
MapUtils.addGeoreferenceLayer(map, props.id, { | ||
manifest: props.manifest, | ||
opacity: props.opacity, | ||
url: props.url | ||
}); | ||
|
||
return () => MapUtils.removeLayer(map, props.id); | ||
}, [map]); | ||
|
||
return null; | ||
}; | ||
|
||
WarpedImageLayer.defaultProps = { | ||
opacity: 0.5 | ||
}; | ||
|
||
export default WarpedImageLayer; |
Oops, something went wrong.