Back to blog

9/10/2026 | 2 min read

Real-Time Geospatial Mapping: Building 'Petrol Koi' with Next.js, Leaflet, and Spatial Queries

How I architected a live geospatial fuel availability tracking web app during regional shortages, featuring GPS bounding-box spatial clustering, instant search, and zero-latency mobile rendering.

Next.jsGeospatialLeafletReactFullStackPerformance
Real-Time Geospatial Mapping: Building 'Petrol Koi' with Next.js, Leaflet, and Spatial Queries
During acute fuel shortages, drivers often waste valuable fuel traveling from one filling station to another only to find pumps dry. To solve this problem in Lalmonirhat, I engineered **Petrol Koi**, a live, crowdsourced and station-verified geospatial tracking web application. Building an interactive map application that performs smoothly on budget Android devices across low-bandwidth mobile networks required strict optimization choices. ## Choosing the Architecture: Next.js + Leaflet While Google Maps is the standard choice for web applications, it carries heavy JavaScript initialization overhead (~300KB+ gzipped) and strict API billing limits. For a public utility tool designed for instantaneous mobile access, I chose **Leaflet** combined with OpenStreetMap raster tiles: - **Initial bundle payload**: Under 45KB gzipped. - **Client-Side Rendering**: Leaflet map components are loaded dynamically with `next/dynamic` and `ssr: false` to avoid window/DOM mismatch errors during SSR. ```tsx // Dynamic Leaflet container loading import dynamic from 'next/dynamic'; export const LiveStationMap = dynamic( () => import('./LiveStationMapInner'), { ssr: false, loading: () => ( Initializing GPS Coordinates... ), } ); ``` ## Bounding-Box Spatial Queries Rather than sending all stations in the database to the client and filtering in memory, the API accepts map viewport bounding coordinates (`north, south, east, west`): ```sql SELECT id, station_name, octane_status, diesel_status, latitude, longitude FROM fuel_stations WHERE latitude BETWEEN $1 AND $2 AND longitude BETWEEN $3 AND $4 AND is_active = true; ``` This spatial indexing allows the application to query thousands of regional points in under 4ms on PostgreSQL. ## Marker Clustering & Live Status Indicators Stations display live color-coded pulsing pins: - 🟢 **Green**: Octane & Diesel in stock - 🟡 **Amber**: Limited stock (rationed) - 🔴 **Red**: Out of stock Combining Leaflet MarkerCluster with lightweight CSS pulse animations gives users an instantaneous visual overview of local fuel availability without needing to tap through multiple menus.

Comments

0 replies

0/2000 characters

  • No comments yet. Be the first to share your thoughts.

About Me

Rahim Badsa is a Full Stack Web Developer from Bangladesh, specializing in MERN, Next.js, Shopify, and WordPress for practical business-focused web products.

Downloads

Contact Info

Lalmonirhat, Bangladesh

[email protected]

+880 1877-104723

FAQ

Who is Rahim Badsa?

Rahim Badsa is a Full Stack Web Developer and Shopify App Developer from Bangladesh who builds production-ready web solutions using MERN, Next.js, Shopify, and WordPress. He is also the Co-founder of Rank Fast LLC and works as a Web Developer at Trinet Digital Agency.

What kind of developer is Rahim Badsa?

Rahim Badsa (also spelled Rahim Badsa, Rahim Badsha, or Rohim Badsa) is a Bangladeshi full stack web developer specializing in MERN stack, Next.js, Shopify, and WordPress development. He has delivered 100+ projects including SaaS dashboards, Shopify custom apps, WooCommerce stores, and SEO-optimized business websites.

What technologies does Rahim Badsa use?

Rahim Badsa works mainly with the MERN stack (MongoDB, Express, React, Node.js), Next.js, TypeScript, Shopify Liquid, and WordPress, alongside Tailwind CSS, PostgreSQL, Prisma, Docker, and modern frontend tools. As a full stack developer, he handles both frontend UI and backend API development, database design, deployment, and technical SEO.

Is Rahim Badsa available for freelance or remote work?

Yes. Rahim Badsa is available for freelance, contract, and fully remote collaboration with clients worldwide. Whether you need a Shopify developer, MERN stack developer, Next.js developer, or WordPress developer, he can help. You can reach out through the contact section on this portfolio or via LinkedIn.

Rahim Badsa Copyright 2026. All rights reserved.