diff options
| author | Yuval Adam <_@yuv.al> | 2019-10-15 23:34:54 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2019-10-16 10:31:54 +0300 |
| commit | 67a1524062f1fc2e45a9f35dbb582e072315ef9e (patch) | |
| tree | dc1fabf984fdd0b3ed277a490432f50e62c78e17 /src/Map.js | |
| parent | cad678c781b7d137470c0efa06b4f911eacc2000 (diff) | |
Initial fetchImages() implementation doesn't work due to CORS
Diffstat (limited to 'src/Map.js')
| -rw-r--r-- | src/Map.js | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -1,8 +1,10 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import ReactMapboxGl, { Layer, Feature } from 'react-mapbox-gl'; + +import { IMAGES_BASE_URL, MAPBOX_ACCESS_TOKEN } from './config'; + import 'mapbox-gl/dist/mapbox-gl.css'; -const MAPBOX_ACCESS_TOKEN = 'pk.eyJ1IjoieXV2YWRtIiwiYSI6ImNpcnMxbzBuaTAwZWdoa25oczlzZmkwbHcifQ.UHtLngbKm9O8945pJm23Nw'; const Mapbox = ReactMapboxGl({ accessToken: MAPBOX_ACCESS_TOKEN, @@ -14,6 +16,16 @@ const Mapbox = ReactMapboxGl({ function Map() { const [center, setCenter] = useState([35, 31.9]); const [zoom, setZoom] = useState([6.3]); + const [images, setImages] = useState({}); + + useEffect(() => { + const fetchImages = async() => { + const res = await fetch(`${IMAGES_BASE_URL}/imgs.json`); + const imgs = await res.json(); + setImages(imgs); + }; + fetchImages(); + }, []); return ( <Mapbox style="mapbox://styles/mapbox/dark-v9" center={center} zoom={zoom} |
