Overview
This module provides functions to:- Scrape Google Maps saved places using Puppeteer
- Parse place data into structured JSON
- Sync places to Notion database
- Manage duplicate detection
Types
Place
Represents a geographical place with metadata.The name of the place
Full street address
Latitude coordinate
Longitude coordinate
User notes or description
Timestamp in milliseconds when place was saved
Google Maps internal graph ID
Functions
parseArrayToJson()
Converts Google Maps raw array data into a structured Place object.Raw array data from Google Maps APP_INITIALIZATION_STATE
Parsed place object with structured fields
getData()
Scrapes Google Maps saved places using Puppeteer and saves to JSON file. Process:- Launches headless Chrome browser with Chromium
- Navigates to Google Maps place list URL
- Extracts
APP_INITIALIZATION_STATEfrom window object - Parses nested array structure
- Saves to
public/places.json
Writes parsed data to
public/places.json- Uses
@sparticuz/chromiumfor serverless environments - Headless mode enabled
- 30-second navigation timeout
- 500ms wait for dynamic content
getExistingPages()
Queries Notion places database and returns a map of existing coordinates.Map with keys as “latitude,longitude” and values as place names
createPlacePage()
Creates a new place entry in the Notion database.Place object to create in Notion
Notion API response with created page details
name(title): Place nameaddress(rich_text): Full addresslatitude(number): Latitude coordinatelongitude(number): Longitude coordinatenotes(rich_text): User notestimestampMs(number): Save timestampgraphId(rich_text): Google Maps graph ID
writeToNotion()
Readspublic/places.json and syncs new places to Notion database.
Process:
- Reads JSON file from
public/places.json - Fetches existing pages from Notion
- Checks for duplicates using coordinates
- Creates new pages for unique places
- Logs skipped and created pages
Logs summary of created and skipped pages
Usage Example
Configuration
File path where scraped places data is saved
Environment variable for Notion places database ID
Related
- Used by: Map component (
src/components/Map.tsx:20) - Depends on:
src/lib/notion-cms.ts,src/lib/notion-client.ts - Source:
src/lib/places.ts:1