-
|
I'm new to working with databases, but I'm diving into a personal project where I need to display a large number of points on a map using the GEOJson format. The app's performance degrades when each point has its own GEOJson source file. This is why I'm looking at ways to consolidate them all into a single call/file. Below is the code I've been using. For some reason, the view isn't accessible via the API. Could someone help me identify any issues with my code or suggest possible improvements? Also, I'm trying to understand the difference between using the List Records API and the View API when accessing data. Could someone explain how they differ and in which scenarios each should be used? CREATE TABLE locations ( ** //// ////** INSERT INTO //// //// CREATE VIEW IF NOT EXISTS location_geojson AS //// //// |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
I've made some progress! I’ve discovered how to combine all of my entries into a single FeatureCollection for a GeoJSON file. Now I can clean up the GeoJSON output on each API call or subscription. Below is some sample code for anyone who needs it (and would like feedback). CREATE TABLE locations ( INSERT INTO CREATE VIEW location_geojson AS |
Beta Was this translation helpful? Give feedback.


I've made some progress!
I’ve discovered how to combine all of my entries into a single FeatureCollection for a GeoJSON file.
Now I can clean up the GeoJSON output on each API call or subscription. Below is some sample code for anyone who needs it (and would like feedback).
CREATE TABLE locations (
id INTEGER PRIMARY KEY,
name TEXT,
lat REAL,
long REAL,
geojson TEXT GENERATED ALWAYS AS (
'{"type": "Feature", "geometry": {"type": "Point", "coordinates": [' || long || ', ' || lat || ']}}'
) VIRTUAL
) STRICT;
INSERT INTO
locations (name, lat, long)
VALUES
('Coffee Corner', 37.7749, -122.4194),
('Book Nook', 40.7128, -74.0060),
('Bike Hub', 34.0522, -118.2437);
CREATE VIEW location_geojson AS
…