-
Notifications
You must be signed in to change notification settings - Fork 8
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 #268 from tsaiDavid/main
Add example for StaticImage
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Image from '../../../../lib/layer/Image.js'; | ||
import ImageStatic from '../../../../lib/source/ImageStatic.js'; | ||
import Map from '../../../../lib/Map.js'; | ||
import Projection from 'ol/proj/Projection.js'; | ||
import React from 'react'; | ||
import View from '../../../../lib/View.js'; | ||
import {getCenter} from 'ol/extent.js'; | ||
|
||
const extent = [0, 0, 1024, 968]; | ||
const projection = new Projection({ | ||
code: 'xkcd-image', | ||
units: 'pixels', | ||
extent, | ||
}); | ||
|
||
function StaticImage() { | ||
return ( | ||
<Map> | ||
<View | ||
options={{projection, center: getCenter(extent), zoom: 2, maxZoom: 8}} | ||
/> | ||
<Image> | ||
<ImageStatic | ||
options={{ | ||
attributions: '© <a href="http://xkcd.com/license.html">xkcd</a>', | ||
url: 'https://imgs.xkcd.com/comics/online_communities.png', | ||
projection, | ||
imageExtent: extent, | ||
}} | ||
/> | ||
</Image> | ||
</Map> | ||
); | ||
} | ||
|
||
export default StaticImage; |
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,11 @@ | ||
--- | ||
title: 'Static Image' | ||
level: 0 | ||
description: | | ||
This example uses a [static image](https://xkcd.com/256/) as a layer source. | ||
The map view is configured with a custom projection that translates image coordinates directly into map coordinates. | ||
--- | ||
|
||
import StaticImage from '../../components/examples/StaticImage.jsx'; | ||
|
||
<StaticImage client:only="react" /> |