This package offers a UI component with which an overview map can be integrated. This helps the user to better understand the current map view in a larger scale context.
To integrate the overview map in your app, add the component (with a map) and configure a layer to be shown in the overview map:
const overviewMapLayer = ... // an OpenLayers layer, see below
<OverviewMap map={map} olLayer={overviewMapLayer} />; /* instead of passing the map, the `DefaultMapProvider` can alternatively be used */
The OverviewMap requires an OpenLayers Layer object in the olLayer property, for example:
// Layer construction is wrapped in useMemo to avoid needless reconstructions on render.
// You can also use a service or different shared state to construct your layer.
const overviewMapLayer = useMemo(
() =>
new TileLayer({
source: new OSM()
}),
[]
);
// Later ...
<OverviewMap map={map} olLayer={overviewMapLayer} />;
NOTE: Keep in mind that an OpenLayers
Layerobject should only be used from (at most) a single map. This means that theolLayerused here should be a new layer instance that is not used anywhere else. Most importantly, you cannot use an.olLayerfrom theMapModeldirectly.
The OverviewMap component uses a default height of 200px and width of 300px.
To override the default size, use the height and width properties.
Both properties support the usual values supported by Chakra UI:
<OverviewMap map={map} olLayer={overviewMapLayer} height="300px" width="400px" />
Apache-2.0 (see LICENSE file)