Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions samples/deckgl-arclayer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Google Maps JavaScript Sample

## deckgl-arclayer

This example uses arcs to show curved point-to-point connections between airports and the city of Prague.

## Setup

### Before starting run:

`npm i`

### Run an example on a local web server

`cd samples/deckgl-arclayer`
`npm start`

### Build an individual example

`cd samples/deckgl-arclayer`
`npm run build`

From 'samples':

`npm run build --workspace=deckgl-arclayer/`

### Build all of the examples.

From 'samples':

`npm run build-all`

### Run lint to check for problems

`cd samples/deckgl-arclayer`
`npx eslint index.ts`

## Feedback

For feedback related to this sample, please open a new issue on
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
22 changes: 22 additions & 0 deletions samples/deckgl-arclayer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<!--
@license
Copyright 2026 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_deckgl_arclayer] -->
<html>
<head>
<title>deck.gl ArcLayer</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly", internalUsageAttributionIds: "gmp_git_jsapisamples_v1_deckgl-arclayer" });</script>
<script type="module" src="./index.js"></script>
</head>
<body>
<gmp-map center="50,14" map-id="90f87356969d889c" zoom="3"></gmp-map>
</body>
</html>
<!-- [END maps_deckgl_arclayer] -->
53 changes: 53 additions & 0 deletions samples/deckgl-arclayer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2026 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/

// [START maps_deckgl_arclayer]
import { GoogleMapsOverlay } from '@deck.gl/google-maps';
import { ArcLayer } from '@deck.gl/layers';
import type * as GeoJSON from 'geojson';

type Properties = { scalerank: number };
type Feature = GeoJSON.Feature<GeoJSON.Point, Properties>;
type Data = GeoJSON.FeatureCollection<GeoJSON.Point, Properties>;

//let map;

async function initMap() {
// Request needed libraries.
(await google.maps.importLibrary('maps')) as google.maps.MapsLibrary;

// Get the gmp-map element.
const mapElement = document.querySelector(
'gmp-map'
) as google.maps.MapElement;

// Get the inner map.
const innerMap = mapElement.innerMap;

innerMap.setTilt(30); // Set tilt after map initialization.

const flightsLayer = new ArcLayer<Feature>({
id: 'flights',
data: '/ne_10m_airports.geojson', // See public/ne_10m_airports.geojson
dataTransform: (data: any) =>
data.features.filter((f: any) => f.properties.scalerank < 4),
getSourcePosition: () => [14.42076, 50.08804], // Prague
getTargetPosition: (f: Feature) =>
f.geometry.coordinates as [number, number],
getSourceColor: [0, 128, 200],
getTargetColor: [0, 0, 80],
getWidth: 1,
});

const overlay = new GoogleMapsOverlay({
layers: [flightsLayer],
});

overlay.setMap(innerMap);
}

initMap();
// [END maps_deckgl_arclayer]
17 changes: 17 additions & 0 deletions samples/deckgl-arclayer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@js-api-samples/deckgl-arclayer",
"version": "1.0.0",
"scripts": {
"build": "tsc && bash ../jsfiddle.sh deckgl-arclayer && bash ../app.sh deckgl-arclayer && bash ../docs.sh deckgl-arclayer && npm run build:vite --workspace=. && bash ../dist.sh deckgl-arclayer",
"test": "tsc && npm run build:vite --workspace=.",
"start": "tsc && vite build --base './' && vite",
"build:vite": "vite build --base './'",
"preview": "vite preview"
},
"dependencies": {
"@deck.gl/core": "^9.2.10",
"@deck.gl/google-maps": "^9.2.10",
"@deck.gl/layers": "^9.2.10",
"deck.gl": "^9.2.10"
}
}
Loading
Loading