openlayers / openlayers/openlayers
How to rotate static image in openlayers 6.9 using turf and imageExtent
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 12.6k
- Forks
- 3.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 21
Description
I need to create and rotate a static image layer in openlayers 6.
The creation of static image is working using url and imageExtent and i can see the image inside the map.
new ImageLayer({
source: new Static({
url,
imageExtent: [
extent.west,
extent.south,
extent.east,
extent.north
]
})
Now, I need to rotate this image using Turfjs
So i did this code that rotate using transformRotate from Turfjs:
const poly = bboxPolygon([
extent.west,
extent.south,
extent.east,
extent.north
])
const rotatedPoly = transformRotate(poly, -extent.rotation, {})
const leftBottom = JSON.parse(JSON.stringify(rotatedPoly.geometry.coordinates[0][0]))
const rightBottom = JSON.parse(JSON.stringify(rotatedPoly.geometry.coordinates[0][1]))
const rightTop = JSON.parse(JSON.stringify(rotatedPoly.geometry.coordinates[0][2]))
const leftTop = JSON.parse(JSON.stringify(rotatedPoly.geometry.coordinates[0][3]))
const bounds = [leftBottom, leftTop, rightTop, rightBottom]
return new ImageLayer({
source: new Static({
url,
imageExtent: bounds
})
})
The last block code is not working, i see nothing inside the map.
mes coordinates are in 'EPSG:4326'
Any idea please ?. Any solution that may be help even without Turfjs ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ImageLayer and Static source usage shown in the issue, then check how imageExtent handles EPSG:4326 coordinates and whether rotated bounds are supported. Done means the rotated static image is visible in the map; the issue does not name a file or test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100