Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for StaticImage #268

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions site/src/components/examples/StaticImage.jsx
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;
11 changes: 11 additions & 0 deletions site/src/content/examples/static-image.mdx
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" />