new host, new basemap

master
gman 3 years ago
parent 600ceb84f8
commit d5f8e46d00

@ -2,10 +2,12 @@ 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, {Source, Layer} from 'react-map-gl/maplibre'; import Map, {Source, Layer} from 'react-map-gl/maplibre';
import mapstyle from './assets/basemap.json';
import { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import Fuse from 'fuse.js' import Fuse from 'fuse.js'
// import mapstyle from './assets/basemap.json';
import mapstyle from './assets/basemap-mapbox.json';
export function KartaPage() { export function KartaPage() {
const mapRef = useRef(null); const mapRef = useRef(null);
const [initial, setInitial] = useState(null); const [initial, setInitial] = useState(null);
@ -14,9 +16,11 @@ export function KartaPage() {
const [selected, setSelected] = useState(-1); const [selected, setSelected] = useState(-1);
const [cursor, setCursor] = useState('grab'); const [cursor, setCursor] = useState('grab');
const host = "https://strapi.iamonlyherefortheicecream.gq"
useEffect(() => { useEffect(() => {
// let initialArticles // let initialArticles
fetch("http://strapi.wg.gateway.ts/api/articles?populate=*") fetch(`${host}/api/articles?populate=*`)
.then(r => r.json()) .then(r => r.json())
.then(d => { .then(d => {
setInitial(d.data) setInitial(d.data)
@ -71,14 +75,14 @@ export function KartaPage() {
cursor={cursor} cursor={cursor}
mapStyle={mapstyle} mapStyle={mapstyle}
interactiveLayerIds={['points-layer']} interactiveLayerIds={['points-layer']}
onClick={e => e.features[0] ? setSelected(e.features[0].properties.id) : setSelected(-1)} onClick={e => {e.features[0] ? setSelected(e.features[0].properties.id) : setSelected(-1); console.log(e.features)}}
onMouseEnter={() => setCursor('pointer')} onMouseEnter={() => setCursor('pointer')}
onMouseLeave={() => setCursor('grab')} onMouseLeave={() => setCursor('grab')}
> >
<Source <Source
id='points' id='points'
type='vector' type='vector'
tiles={['http://strapi.wg.gateway.ts/tiles/{z}/{x}/{y}.pbf']} tiles={[`${host}/tiles/{z}/{x}/{y}.pbf`]}
maxzoom={10} maxzoom={10}
> >
<Layer <Layer
@ -126,7 +130,7 @@ export function KartaPage() {
{articles !== null && articles.length > 0 && articles.map(article => { {articles !== null && articles.length > 0 && articles.map(article => {
const articleInfo = { const articleInfo = {
"id": article.id, "id": article.id,
"image": article.attributes.cover.data !== null ? "http://strapi.wg.gateway.ts" + article.attributes.cover.data.attributes.url : "", "image": article.attributes.cover.data !== null ? host + article.attributes.cover.data.attributes.url : "",
"category": "Памятные места", "category": "Памятные места",
"title": article.attributes.title, "title": article.attributes.title,
"address": article.attributes.address, "address": article.attributes.address,

@ -0,0 +1,19 @@
{
"version": 8,
"name": "Mapbox litmap",
"metadata": {},
"sources": {
"mapbox": {
"type": "raster",
"tiles": ["https://api.mapbox.com/styles/v1/ghermant/clo49ljc700b901pghvgk0o7u/tiles/512/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiZ2hlcm1hbnQiLCJhIjoiY2pncDUwcnRmNDQ4ZjJ4czdjZXMzaHZpNyJ9.3rFyYRRtvLUngHm027HZ7A"]
}
},
"layers": [
{
"id": "basemap",
"type": "raster",
"source": "mapbox",
"paint": {}
}
]
}
Loading…
Cancel
Save