Managing location coordinates inside a spreadsheet is frustrating when you cannot see where your pins actually land. One swapped sign or typo in a latitude or longitude cell can place a customer site, delivery stop, or field asset miles away—or even in the middle of the ocean.
Built-in Google Sheets Geo Charts only render static hover maps without street-level zoom, pin dragging, or two-way editing. Meanwhile, third-party mapping add-ons often lock editing features behind paid subscriptions or require you to configure Google Cloud billing and API keys.
By combining Google Apps Script (HtmlService) with the open-source Leaflet.js library, you can dock a tall, interactive map right inside your Google Sheets sidebar. Search any location from a built-in searchable dropdown, click pins to view all row details inside a clean map bubble, drag markers to fix coordinates, and save updated latitude and longitude values straight back to your sheet—with $0 setup and no API key required.
Table of Contents
When Do You Need This Solution?
This sidebar map is built specifically for workflows where your source of truth lives in Google Sheets, and you need fast visual verification and coordinate cleanup without leaving your spreadsheet:
- Auditing and fixing inaccurate GPS coordinates: Field teams, logistics coordinators, and data analysts who collect latitude and longitude values from forms, GPS devices, or legacy exports and need to visually drag misplaced pins onto the exact building, entrance, or road.
- Cleaning and correcting field survey data: Researchers, GIS analysts, and survey teams who collect responses via mobile forms (such as Google Forms, KoboToolbox, or ODK) and need to spot GPS drift, verify respondent locations, and drag off-target pins onto the exact surveyed household, facility, or plot.
- Managing delivery stops, service routes, or field assets: Small businesses and operations teams tracking customer addresses, inspection sites, utility poles, or branch locations in Google Sheets who want to look up any record quickly and inspect its details on a street-level map.
- Working without Google Cloud billing or paid add-ons: Google Sheets users who want a self-contained, custom mapping tool inside their spreadsheet without managing API keys, monthly quotas, or third-party add-on subscriptions.
- Keeping additional data columns intact while updating coordinates: Datasets with 5, 10, or 20+ descriptive columns (ID, Customer Name, Phone, Status, Notes) where you only want to adjust Latitude and Longitude while displaying the rest of the row inside the map popup bubble.
Key Benefits of This Approach
| Benefit | Why It Matters in Day-to-Day Work |
| $0 Cost & No API Key Required | Uses Google Apps Script (HtmlService) and Leaflet.js with OpenStreetMap tiles—no Google Maps API key, no credit card, and no Google Cloud project setup. |
| Plug-and-Play with Any Extra Columns | Reads Latitude (Col A) and Longitude (Col B) and automatically displays every remaining column (Col C onward) inside the marker’s popup bubble using your Row 1 headers. |
| Searchable Dropdown Selector | Type any keyword, row number, ID, or name inside the top dropdown to filter matching records and fly straight to that pin on the map. |
| Safe Two-Way Coordinate Editing | Dragging a marker updates only the Latitude and Longitude inputs in the sidebar and writes back to Columns A & B on that exact row—leaving your other columns untouched. |
| 100% Code Ownership | The entire tool lives inside your spreadsheet’s Apps Script project (Code.gs and Sidebar.html), so you own it and can customize it freely. |
Quick Start: Copy the Template and Use Your Own Data in 2 Minutes
You do not need to write any code to start using this tool right away:
- Copy the workbook to your Google Drive: Open the Interactive Map Sidebar Template and click Make a copy to save your own private version in Google Drive.
- Prepare your dataset: In your data table, move your Latitude column to Column A and your Longitude column to Column B. Place all other columns (such as ID, Name, Address, Status, or Notes) starting in Column C onward.
- Replace the sample rows: Paste your dataset into the
Locationstab (keeping Row 1 as your column headers). - Launch the sidebar: Wait a few seconds for the custom Map Tools menu to appear at the top of Google Sheets, then click Map Tools → Open Location Map Sidebar.
- Authorize once: When prompted by Google, click Review Permissions → Choose your Google Account → Advanced → Go to [Project Name] (unsafe) → Allow. Your pins will load on the map immediately.
How the Two-Way Sidebar Architecture Works

- Dynamic Read (
getLocations):Code.gsreads Column A (Lat), Column B (Lng), and dynamically loops through Column C to the last column using your Row 1 headers as field labels. - Search & Inspect: The sidebar populates a searchable dropdown and places a draggable Leaflet marker for every valid coordinate pair. Clicking a pin opens a map bubble showing the row number and all extra columns (
Col C+). - Drag & Save (
updateCoordinates): Dragging a marker updates the Latitude and Longitude fields live. Clicking Save Coordinates to Sheet writes onlyCol AandCol Bback to that exact row number.
Full Source Code (If Building from Scratch)
If you prefer to add this to an existing Google Sheet manually, make sure your target tab is named Locations with Latitude in Column A and Longitude in Column B, then open Extensions → Apps Script and add these two files.
Customize the Code for Your Exact Dataset with AI
If you cannot move your Latitude and Longitude columns to Columns A and B—or if you want extra features tailored to your spreadsheet—you can regenerate the script in seconds using Gemini.
- Open Gemini and either upload your CSV file or paste your Google Sheet tab name + Row 1 headers and 2–3 sample rows.
- Copy and paste this prompt along with your dataset:
Create a Google Apps Script sidebar map (`Code.gs` and `Sidebar.html`) for the dataset I have attached or connected in this chat. Use HtmlService and Leaflet.js (with OpenStreetMap tiles—no Google Maps API key or billing required).
Dataset Instructions:
- Automatically inspect my attached/connected dataset to identify the sheet tab name (default to "Locations" if using a CSV), the Latitude column, the Longitude column, and all remaining descriptive columns.
- Map the code directly to the exact column positions found in my file so I do not need to rearrange my columns.
Requirements:
1. Add a custom menu ("Map Tools" -> "Open Location Map Sidebar") that opens a 360px-wide right-hand sidebar.
2. Include a custom searchable dropdown selector at the top (with a search input box inside the dropdown panel to filter by any row value) and a "Reload" button.
3. Plot draggable markers for every row with valid coordinates and dynamically display all remaining columns (using Row 1 headers as labels) inside the marker's popup bubble.
4. Allow editing ONLY Latitude and Longitude in the sidebar form (updating live to 6 decimal places when a pin is dragged) and save them back to their exact columns on that specific row without overwriting or altering any other columns.How You Can Improve This Further
Once your basic coordinate editor is running, consider extending it with any of these upgrades:
- Add a New Pin by Clicking the Map: Listen for a map click (
map.on('click', ...)) when a “New Location” toggle is active, populate the coordinates, and append a brand-new row to the bottom of your sheet. - Color-Coded Markers by Category or Status: Read a
StatusorCategorycolumn (such as Active, Pending, or Completed) and assign green, orange, or blue Leaflet marker icons so you can spot priorities at a glance. - Marker Clustering for Large Sheets: If you have more than 200–300 rows, include the Leaflet.markercluster plugin so dense pins group cleanly at low zoom levels and stay snappy inside the sidebar.
- Address Search & Auto-Geocoding: Add a geocoding helper in
Code.gsusing Google Apps Script’s built-inMaps.newGeocoder()service to convert street addresses into initial Latitude and Longitude values before fine-tuning pins on the map. - Layer Switcher (Street vs. Satellite Imagery): Add Leaflet’s
L.control.layers()so users can toggle between standard street maps and satellite imagery when verifying rooftops, driveways, or rural sites.
Frequently Asked Questions (FAQ)
Why do Latitude and Longitude need to be in Columns A and B in the template?
Putting Latitude in Column A and Longitude in Column B lets Code.gs dynamically read all remaining columns from Column C onward—no matter whether your sheet has 4 columns or 25 columns—and display them cleanly inside each pin’s map bubble without hardcoding column letters.
Does saving coordinates overwrite formulas or text in other columns?
No. updateCoordinates() only writes to sheet.getRange(rowNumber, 1, 1, 2) (Columns A and B on that specific row), leaving Column C onward completely untouched.
Do I need a Google Maps API key or Google Cloud billing account?
No. The map renders inside Sidebar.html using Leaflet.js and OpenStreetMap tiles, and all spreadsheet reads and writes run natively through Google Apps Script.
What are the limitations of building an interactive map in a Google Sheets sidebar?
There are four main constraints to keep in mind:
- Desktop browsers only: Google Apps Script custom sidebars do not open in the Google Sheets Android or iOS mobile apps.
- Narrow panel width: Google Sheets restricts custom sidebars to roughly 300–360px wide, which works well for coordinate editing and map bubbles but is not suited for wide multi-column dashboards.
- Manual reload for external sheet edits: If you or a teammate edit cells directly in the spreadsheet while the sidebar is open, click Reload so the map syncs with the latest row numbers and values.
- Best for small-to-medium datasets: Rendering hundreds of individual draggable markers works smoothly, while sheets with 500+ rows benefit from adding marker clustering (
Leaflet.markercluster) and respecting OpenStreetMap’s fair-use tile policy.
