Comments (8)
Yes, it looks ok, what happens when you do this?
from rlayers.
it's freezing the window; I'm using Next 13 but have not had any issues using the other Rlayers examples. I'm using it as a dynamic component.
This is the full component
import IIIFInfo, { ImageInformationResponse } from 'ol/format/IIIFInfo'
import { Tile as LayerTile } from 'ol/layer'
import 'ol/ol.css'
import IIIF from 'ol/source/IIIF'
import React, { useEffect, useState } from 'react'
import { RContextType, RLayer, RMap } from 'rlayers'
import { RLayerRasterProps } from 'rlayers/layer/RLayerRaster'
export interface RLayerIIIFProps extends RLayerRasterProps {
url?: string
iiifManifest: string | ImageInformationResponse
}
class RLayerIIIF extends RLayer<RLayerIIIFProps> {
ol: LayerTile<IIIF>
source: IIIF
constructor(
props: Readonly<RLayerIIIFProps>,
context: React.Context<RContextType>
) {
super(props, context)
this.createSource()
this.ol = new LayerTile({ source: this.source })
this.eventSources = [this.ol, this.source]
}
createSource(): void {
const options = new IIIFInfo(
this.props.iiifManifest
).getTileSourceOptions()
if (options === undefined || options.version === undefined) {
throw new Error('manifest is not valid IIIF configuration')
}
this.source = new IIIF({ ...options, zDirection: -1 })
this.eventSources = [this.ol, this.source]
}
refresh(prevProps?: RLayerIIIFProps): void {
super.refresh(prevProps)
if (prevProps?.url !== this.props.url) this.createSource()
}
}
export default function IiifTile(): JSX.Element {
const url =
'https://iiif.ub.uni-leipzig.de/iiif/j2k/0000/0107/0000010732/00000072.jpx/info.json'
const [manifest, setManifest] = useState<
string | ImageInformationResponse
>()
useEffect(() => {
fetch(url)
.then((response) => response.json())
.then((imageInfo) => {
setManifest(imageInfo)
})
}, [])
if (manifest) {
return (
<RMap
width={'100%'}
height={'60vh'}
initial={{ center: [0, 0], zoom: 1 }}
>
<RLayerIIIF iiifManifest={manifest} url={url} />
</RMap>
)
}
return <p>loading</p>
}
from rlayers.
This is not an rlayers problem, this layer generates an unreasonable amount of tiles. You probably need to readjust the tilegrid or the zoom level.
from rlayers.
For anyone encountering the same issue, solution was to utilise external state to load the IIIF:
export interface RLayerIIIFProps extends RLayerRasterProps {
iiif: IIIF
}
export interface IiifTIleProps {
url: string
}
class RLayerIIIF extends RLayer<RLayerIIIFProps> {
ol: LayerTile<IIIF>
source: IIIF
constructor(
props: Readonly<RLayerIIIFProps>,
context: React.Context<RContextType>
) {
super(props, context)
this.source = this.props.iiif
this.ol = new LayerTile({ source: this.source })
this.eventSources = [this.ol, this.source]
}
}
export default function IiifTile({ url }: IiifTIleProps) {
const [iiif, setIiif] = useState<IIIF>()
const [error, setError] = useState<string>()
useEffect(() => {
fetch(url)
.then((response) => response.json())
.then((imageInfo) => {
const options = new IIIFInfo(imageInfo).getTileSourceOptions()
if (options === undefined || options.version === undefined) {
setError(
'Data seems to not be valid IIIF image information.'
)
return
}
setIiif(new IIIF({ ...options, zDirection: -1 }))
})
}, [url])
if (error) return <p>error</p>
if (iiif) {
return (
<RMap
width={'100%'}
height={'60vh'}
initial={{
center: [0, 0],
zoom: 1,
}}
extent={iiif.getTileGrid()?.getExtent()}
>
<RLayerIIIF iiif={iiif} />
</RMap>
)
}
return <p>loading</p>
}
from rlayers.
I think you should report this in OpenLayers - calling setSize
produces an unreasonable amount of tiles
from rlayers.
I don't think I understand the code well enough to describe the issue well enough in a report.
from rlayers.
case in point: would you be able to point me in the right direction as to why the the IIIF layer in rlayers restricts the ability to zoom out (sandbox link) unlike the implementation in open layers?
from rlayers.
rlayers uses the same implementation, my only guess would be that Openlayers has a bug that manifests itself only when you create an element and then set its size via the setSize
function - unlike the example
from rlayers.
Related Issues (20)
- Gesture overlay and handling HOT 3
- Performance issues with RDraw HOT 4
- Support for tailwindcss? HOT 3
- Uncaught DOMException when removing an `ROverlay` HOT 1
- Change RCircle radius when zoom changes HOT 1
- How to add KML as layer vector HOT 1
- Remove last point event RDraw
- Typescript error cannot use Component as a JSX Component HOT 4
- persist map context HOT 1
- Snaping in interaction HOT 1
- How do I configure tileSize? HOT 1
- format problem in WMS WMTS HOT 4
- npm ERR! Could not resolve dependency: ol@"^8.0.0" and [email protected] HOT 1
- rlayers not supported for OpenLayers 8.0.0 HOT 4
- Is it possible to dinamically add/remove layer from RMAP? HOT 7
- Question on how to manage events on layers components HOT 2
- Adding a print control
- is it possible to do layer pixel manipulation? HOT 1
- Using non-default projection with OSM and Next.js HOT 3
- RLayerWMTS fetches the wmts file twice HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rlayers.