Note: Make sure you have completed the React Native - Environment Setup instructions till "Creating a new application" step, before proceeding.
Let Metro Bundler run in its own terminal. Open a new terminal from the root of your React Native project. Run the following command to start your Android or iOS app:
npx expo run android
npx expo run ios
Note: Make sure you have completed the Build a User Management App with Expo React Native instructions with setting up a supabase account and project with Auth.
create table if not exists public.scooters (
id int generated by default as identity primary key,
location geography(POINT) not null,
battery float default 0
);
create index scooters_geo_index
on public.scooters
using GIST (location);
insert into public.scooters(location)
values
(st_point(2.1589, 41.3907)),
(st_point(2.1765, 41.3835)),
(st_point(2.1897, 41.3942)),
(st_point(2.1614, 41.3768))...
create or replace function nearby_scooters(lat float, long float)
returns table (id public.scooters.id%TYPE, battery public.scooters.battery%TYPE, lat float, long float, dist_meters float)
language sql
as $$
select id, battery, st_y(location::geometry) as lat, st_x(location::geometry) as long, st_distance(location, st_point(long, lat)::geography) as dist_meters
from public.scooters
order by location <-> st_point(long, lat)::geography;
$$;
EXPO_PUBLIC_MAPBOX_PK=
EXPO_PUBLIC_SUPABASE_URL=
EXPO_PUBLIC_SUPABASE_ANON_KEY=