Slight refactoring

This commit is contained in:
Eric van der Vlist 2022-11-22 15:41:47 +01:00
parent 0d8bc3b2f1
commit 0f8f892688
4 changed files with 9 additions and 6 deletions

View File

@ -1,7 +1,5 @@
import { Redirect, Route } from 'react-router-dom';
import { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router';
import Map from './components/Map/Map';
import { setupIonicReact } from '@ionic/react';
import Map from './components/map';
import 'ol/ol.css';

View File

@ -2,9 +2,11 @@ import React, { useEffect, useRef } from 'react';
import OlMap from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import Attribution from 'ol/control/Attribution';
import OSM, { ATTRIBUTION } from 'ol/source/OSM';
import './Map.css'
import './Map.css';
import Collection from 'ol/Collection';
export interface MapProperties {}
@ -12,6 +14,7 @@ export const Map: React.FC<MapProperties> = (props: MapProperties) => {
const target = useRef<HTMLDivElement>(null);
useEffect(() => {
const controls = new Collection([new Attribution({ collapsible: true })]);
const map = new OlMap({
view: new View({
center: [0, 0],
@ -23,6 +26,7 @@ export const Map: React.FC<MapProperties> = (props: MapProperties) => {
}),
],
target: target.current ?? undefined,
controls,
});
}, []);

View File

@ -0,0 +1 @@
export { default } from './Map';