diff --git a/src/Components/Map/MarkerPopup.tsx b/src/Components/Map/MarkerPopup.tsx
index 4b812905..9af7463c 100644
--- a/src/Components/Map/MarkerPopup.tsx
+++ b/src/Components/Map/MarkerPopup.tsx
@@ -2,7 +2,8 @@ import * as React from 'react'
import { Popup } from 'react-leaflet'
export interface IMarkerPopupProps {
- item: IMapItem;
+ item: IMapItem,
+ tags: ITag[]
}
export interface IMapItem {
@@ -14,7 +15,7 @@ export interface IMapItem {
position: IGeometry,
start?: string,
end?: string,
- tags: ITag[],
+ tags?: string[],
[key: string]:any
}
@@ -24,11 +25,11 @@ export interface IGeometry {
}
export interface ITag {
- Tags_id :
- {
+
color: string;
id: string;
- }
+ name: string;
+
}
const MarkerPopup = (props:IMarkerPopupProps) => {
@@ -40,8 +41,9 @@ const MarkerPopup = (props:IMarkerPopupProps) => {
{item.start || ""} {item.end || ""}
{item.text}
- {item.tags.map((tag:ITag) => (
- #{tag.Tags_id.id}
+ {item.tags&&
+ props.tags.map((tag:ITag) => (
+ #{tag.name}
))}
)
diff --git a/src/index.tsx b/src/index.tsx
index 6c7d0c2d..f18ec65d 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,8 +1,8 @@
-import { TileLayer, MapContainer, Marker, LayersControl } from "react-leaflet";
+import { TileLayer, MapContainer, Marker } from "react-leaflet";
import "leaflet/dist/leaflet.css";
import * as React from "react";
import MarkerIconFactory from './Utils/MarkerIconFactory';
-import MarkerPopup, { IMapItem } from "./Components/Map/MarkerPopup";
+import MarkerPopup, { IMapItem, ITag } from "./Components/Map/MarkerPopup";
import "./styles.scss"
export interface IMapProps {
@@ -12,39 +12,63 @@ export interface IMapProps {
zoom: number,
places?: IMapItem[],
events?: IMapItem[],
- children?: any,
- data?: any,
+ tags?: ITag[],
}
-const Map = (props: IMapProps) => {
+const UtopiaMap = (props: IMapProps) => {
+ let tagMap = new Map(props.tags?.map(key => [key.id, key]));
+
+ const getTags = (item: IMapItem) => {
+ let tags: ITag[] = [];
+ item.tags && item.tags.forEach(element => {
+ if (tagMap.has(element)) { tags.push(tagMap.get(element)!) };
+ });
+ return tags;
+ }
+
+
return (
-
-
- {props.places &&
- (props.places).map((place: IMapItem) => (
-
-
-
- ))
+
+ {props.places &&
+ props.places.map((place: IMapItem) => {
+ let tags = getTags(place);
+ let color1 = "#555";
+ let color2 = "RGBA(35, 31, 32, 0.2)";
+ if (tags[0]) {
+ color1 = tags[0].color;
}
-
-
- {props.events &&
- (props.events).map((event: IMapItem) => (
-
-
-
- ))
+ if (tags[1]) {
+ color2 = tags[1].color;
}
-
-
+
+
+ return (
+
+
+
+ )
+
+ }
+
+ )
+ }
+
+ {props.events &&
+ (props.events).map((event: IMapItem) => (
+
+
+
+ ))
+ }
+
);
}
-export default Map;
+export default UtopiaMap;
+
diff --git a/src/sampleData/data.ts b/src/sampleData/data.ts
deleted file mode 100644
index 8a73bd14..00000000
--- a/src/sampleData/data.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-import { IMapItem } from "../Components/Map/MarkerPopup";
-
-export const events:IMapItem[] = [
- {
- "id": "1af74f62-9fcc-43c2-b63b-cc320dd4fcda",
- "date_created": "2022-05-09T21:35:09.250Z",
- "date_updated": null,
- "name": "bla bla",
- "text": "fsddfsf",
- "position": {
- "type": "Point",
- "coordinates": [
- 10.1233030812617,
- 50.7884682638985
- ]
- },
- "start": "2022-05-17T12:00:00",
- "end": "2022-05-25T12:00:00",
- "tags": [
- {
- "Tags_id": {
- "color": "#75507B",
- "id": "Docutopia"
- }
- },
- {
- "Tags_id": {
- "color": "#3465A4",
- "id": "Coding"
- }
- }
- ]
- },
- {
- "id": "65bbc003-b6de-4904-b85c-8ab6c92fe0db",
- "date_created": "2022-03-14T10:20:11.534Z",
- "date_updated": "2022-04-05T08:58:38.790Z",
- "name": "Hackathon",
- "text": "still in progress",
- "position": {
- "type": "Point",
- "coordinates": [
- 9.97875748947354,
- 51.1204618942726
- ]
- },
- "start": "2022-03-25T12:00:00",
- "end": "2022-05-12T12:00:00",
- "tags": [
- {
- "Tags_id": {
- "color": "#75507B",
- "id": "Docutopia"
- }
- },
- {
- "Tags_id": {
- "color": "#3465A4",
- "id": "Coding"
- }
- }
- ]
- }
-];
-
-export const places = [{
- "id": "938529f4-fa0b-4c98-9381-bda13b0c2ac7",
- "date_created": "2022-04-05T08:20:45.178Z",
- "date_updated": "2022-04-05T08:57:41.311Z",
- "name": "Rainbow Crystal Garten",
- "text": "welcome home",
- "position": {
- "type": "Point",
- "coordinates": [
- 9.50282340471136,
- 51.3348944083875
- ]
- },
- "tags": [
- {
- "Tags_id": {
- "color": "#75507B",
- "id": "Docutopia"
- }
- },
- {
- "Tags_id": {
- "color": "#4E9A06",
- "id": "Rainbow"
- }
- }
- ]
-}];
-