add layer, sync it with search

master
gtitov 3 years ago
parent c747285171
commit ce38e4937c

@ -1,7 +1,7 @@
import { Paper, Flex, ScrollArea, Autocomplete } from '@mantine/core'; import { Paper, Flex, ScrollArea, Autocomplete } from '@mantine/core';
import { ArticleCardVertical } from './ArticleCard'; import { ArticleCardVertical } from './ArticleCard';
import articleCard from './assets/card.json'; import articleCard from './assets/card.json';
import Map from 'react-map-gl/maplibre'; import Map, {Source, Layer} from 'react-map-gl/maplibre';
import mapstyle from './assets/basemap.json'; import mapstyle from './assets/basemap.json';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import Fuse from 'fuse.js' import Fuse from 'fuse.js'
@ -37,7 +37,7 @@ export function KartaPage() {
// ignoreFieldNorm: false, // ignoreFieldNorm: false,
// fieldNormWeight: 1, // fieldNormWeight: 1,
keys: [ keys: [
"attributes.title" "attributes.tags.value"
] ]
}; };
@ -61,7 +61,22 @@ export function KartaPage() {
height: '90vh' height: '90vh'
}} }}
mapStyle={mapstyle} mapStyle={mapstyle}
/> >
<Source
id='points'
type='vector'
tiles={['http://localhost:5500/tiles/{z}/{x}/{y}.pbf']}
maxzoom={10}
>
<Layer
id='points-layer'
type='circle'
source-layer='layer'
filter={articles === null || articles.length == 0 ? false : ['in', 'id', ...articles.map(a => a.id)]}
/>
</Source>
</Map>
<Paper shadow={'md'} withBorder style={{ <Paper shadow={'md'} withBorder style={{
position: 'absolute', position: 'absolute',
top: '1rem', top: '1rem',
@ -92,7 +107,7 @@ export function KartaPage() {
> >
{articles !== null && articles.length > 0 && articles.map(article => { {articles !== null && articles.length > 0 && articles.map(article => {
const articleInfo = { const articleInfo = {
"image": article.attributes.cover.data !== null ? "http://strapi.wg.gateway.ts" + article.attributes.cover.data.attributes.url : "https://images.unsplash.com/photo-1628890923662-2cb23c2e0cfe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&q=80", // "image": article.attributes.cover.data !== null ? "http://strapi.wg.gateway.ts" + article.attributes.cover.data.attributes.url : "https://images.unsplash.com/photo-1628890923662-2cb23c2e0cfe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&q=80",
"category": "technology", "category": "technology",
"title": article.attributes.title, "title": article.attributes.title,
"date": new Date(article.attributes.publishedAt).toLocaleDateString("ru-RU"), "date": new Date(article.attributes.publishedAt).toLocaleDateString("ru-RU"),
@ -108,13 +123,6 @@ export function KartaPage() {
)} )}
{/* <ArticleCardVertical {...articleCard} />
<ArticleCardVertical {...articleCard} />
<ArticleCardVertical {...articleCard} />
<ArticleCardVertical {...articleCard} />
<ArticleCardVertical {...articleCard} />
<ArticleCardVertical {...articleCard} />
<ArticleCardVertical {...articleCard} /> */}
</Flex> </Flex>
</ScrollArea> </ScrollArea>
</Paper> </Paper>

Loading…
Cancel
Save