get all stations sooner
This commit is contained in:
parent
396c9666e3
commit
d0a73ba6a1
2 changed files with 15 additions and 13 deletions
|
@ -4,6 +4,7 @@ import { Layer } from 'solid-map-gl';
|
|||
|
||||
import type { JSX } from 'solid-js';
|
||||
|
||||
import { allStations } from '~/root';
|
||||
|
||||
|
||||
type ScatData = {
|
||||
|
@ -12,23 +13,12 @@ type ScatData = {
|
|||
|
||||
|
||||
export default function MapScatLayer(props: any) {
|
||||
|
||||
async function fetchAllStations() {
|
||||
let buf: ScatData[] = [];
|
||||
const response = await fetch('https://kevinfwu.com/getall');
|
||||
for (const station of await response.json()) {
|
||||
buf.push({ coordinates: [station.Coordinates[1], station.Coordinates[0]] })
|
||||
};
|
||||
console.log('Rendering', buf.length, 'dots!');
|
||||
return (buf);
|
||||
};
|
||||
|
||||
return (
|
||||
<Layer customLayer={
|
||||
new MapboxLayer({
|
||||
id: 'deckgl-scatterplot',
|
||||
type: ScatterplotLayer,
|
||||
data: fetchAllStations(),
|
||||
data: allStations(),
|
||||
pickable: false,
|
||||
stroked: false,
|
||||
lineWidthMaxPixels: 0,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @refresh reload
|
||||
import { A, Body, ErrorBoundary, FileRoutes, Head, Html, Meta, Routes, Scripts, Title } from "solid-start";
|
||||
|
||||
import type { JSX } from "solid-js";
|
||||
import { createSignal, JSX } from "solid-js";
|
||||
|
||||
import { StationsProvider } from "./components/StationsContext";
|
||||
import BadassMap from './components/map/BadassMap';
|
||||
|
@ -9,6 +9,18 @@ import BadassMap from './components/map/BadassMap';
|
|||
import "./root.css";
|
||||
|
||||
|
||||
async function fetchAllStations() {
|
||||
let buf: ScatData[] = [];
|
||||
const response = await fetch('https://kevinfwu.com/getall');
|
||||
for (const station of await response.json()) {
|
||||
buf.push({ coordinates: [station.Coordinates[1], station.Coordinates[0]] })
|
||||
};
|
||||
console.log('Rendering', buf.length, 'dots!');
|
||||
return (buf);
|
||||
};
|
||||
|
||||
export const [allStations, setAllStations] = createSignal(fetchAllStations());
|
||||
|
||||
export default function Root() {
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Reference in a new issue