Skip to content

Commit

Permalink
map test
Browse files Browse the repository at this point in the history
  • Loading branch information
franthormel committed Jun 26, 2024
1 parent 3dda229 commit 374b463
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions app/listings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
"use client"
import PageLayout from "@/components/_app/page-layout";
// TODO: Check if this is really needed

import { Feature, View } from "ol";
import Map from 'ol/Map';
import Point from "ol/geom/Point";
import TileLayer from "ol/layer/Tile";
import VectorLayer from "ol/layer/Vector";
import { fromLonLat } from "ol/proj";
import OSM from "ol/source/OSM";
import VectorSource from "ol/source/Vector";
import { Style, Text } from "ol/style";
import { useEffect } from "react";

export default function Home() {
const mapIconStyle = new Style({
text: new Text({
text: "Hello"
})
})
const mapPositionFeature = new Feature()
mapPositionFeature.setStyle(mapIconStyle)
const point = new Point(fromLonLat([0, 0]));
mapPositionFeature.setGeometry(point)

useEffect(() => {
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new OSM(),
}),
new VectorLayer({
source: new VectorSource({
features: [mapPositionFeature],
}),
})
],
view: new View({
center: [0, 0],
zoom: 2,
}),
});

return () => map.dispose()
}, []);

return (
<main className='flex flex-col gap-5'>
</main>
<PageLayout>
<div id="map" className="w-full h-96" />
</PageLayout>
);
}

0 comments on commit 374b463

Please sign in to comment.