examples/basemap-browser/README.md
A TypeScript/React test application for quickly testing deck.gl with different basemap providers and configurations. Uses React function components throughout.
This example demonstrates both Pure JS and React integration patterns with deck.gl:
src/
├── types.ts # TypeScript type definitions
├── constants.ts # Shared constants
├── layers.ts # Shared layer configurations
├── examples/
│ └── index.ts # Example configurations
├── examples-pure-js/ # Pure JS implementations
│ ├── google-maps.ts
│ ├── mapbox.ts
│ ├── maplibre.ts
│ └── index.ts
├── examples-react/ # React implementations
│ ├── google-maps-component.tsx
│ ├── mapbox-component.tsx
│ ├── maplibre-component.tsx
│ └── index.ts
├── control-panel.tsx # Control panel (separate React root)
└── index.tsx # Entry point
# From the examples/basemap-browser directory
yarn
yarn start-local
Open http://localhost:8080 in your browser.
Window Resize Test: Resize your browser window and verify that:
Device Pixel Ratio Test: Move the browser window between screens with different pixel ratios (e.g., from Retina to non-Retina display) and verify that:
Interleaved vs Overlaid: Toggle the "Interleaved Mode" checkbox and verify:
The basemap browser covers these configurations:
| Provider | Framework | Interleaved |
|---|---|---|
| Google Maps | Pure JS | true |
| Google Maps | Pure JS | false |
| Google Maps | React | true |
| Google Maps | React | false |
| Mapbox | Pure JS | true |
| Mapbox | Pure JS | false |
| Mapbox | React | true |
| Mapbox | React | false |
| MapLibre | Pure JS | true |
| MapLibre | Pure JS | false |
| MapLibre | React | true |
| MapLibre | React | false |
| MapLibre Globe | Pure JS | true |
| MapLibre Globe | Pure JS | false |
| MapLibre Globe | React | true |
| MapLibre Globe | React | false |
To test Google Maps examples, you need to set environment variables:
export GoogleMapsAPIKey="your-api-key"
export GoogleMapsMapId="your-map-id"
Or add them to your .env file. The vite config will automatically inject them.
To add a new basemap example:
src/layers.ts if neededsrc/examples/index.ts:'New Example': {
name: 'New Example',
mapType: 'maplibre', // or 'mapbox' or 'google-maps'
framework: 'react', // or 'pure-js'
mapStyle: MAPLIBRE_STYLE,
initialViewState: {
latitude: 51.47,
longitude: 0.45,
zoom: 4,
bearing: 0,
pitch: 30
},
getLayers: getAirportLayers
}
This browser extracts the core layer configurations from the get-started examples into reusable functions:
src/layers.ts match those in examples/get-started/*/app.jssrc/constants.ts are shared across all examplessrc/examples/index.ts use the same initial view states