or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

datasets.mddirections.mddrawing.mdfigure-map.mdgeojson.mdheatmap.mdindex.mdmarkers.mdtransportation.md

transportation.mddocs/

0

# Transportation and Traffic Layers

1

2

Display real-time and static transportation information including traffic conditions, public transit routes, and bicycling paths. These layers provide contextual information about transportation infrastructure and current conditions.

3

4

## Capabilities

5

6

### Traffic Layer

7

8

Display real-time traffic information with automatic updates and current road conditions.

9

10

```python { .api }

11

def traffic_layer(auto_refresh=True):

12

"""

13

Create a traffic information layer.

14

15

Parameters:

16

- auto_refresh (bool): Whether layer auto-updates traffic data

17

18

Returns:

19

Traffic: Traffic layer instance

20

"""

21

```

22

23

### Traffic Widget

24

25

Widget for displaying current traffic conditions on roads.

26

27

```python { .api }

28

class Traffic:

29

"""

30

Traffic layer widget showing current traffic conditions.

31

32

Attributes:

33

- auto_refresh (bool): Whether layer auto-updates

34

"""

35

```

36

37

### Transit Layer

38

39

Display public transportation routes and stops including buses, trains, and subway systems.

40

41

```python { .api }

42

def transit_layer():

43

"""

44

Create a public transit layer.

45

46

Returns:

47

Transit: Transit layer instance

48

"""

49

```

50

51

### Transit Widget

52

53

Widget for showing public transportation infrastructure.

54

55

```python { .api }

56

class Transit:

57

"""

58

Transit layer widget showing public transport routes and stops.

59

"""

60

```

61

62

### Bicycling Layer

63

64

Display bicycle-friendly routes and cycling infrastructure.

65

66

```python { .api }

67

def bicycling_layer():

68

"""

69

Create a bicycling routes layer.

70

71

Returns:

72

Bicycling: Bicycling layer instance

73

"""

74

```

75

76

### Bicycling Widget

77

78

Widget for showing bicycle routes and cycling infrastructure.

79

80

```python { .api }

81

class Bicycling:

82

"""

83

Bicycling layer widget showing bike routes and cycling infrastructure.

84

"""

85

```

86

87

## Usage Examples

88

89

### Basic Traffic Layer

90

91

```python

92

import gmaps

93

94

gmaps.configure(api_key="YOUR_API_KEY")

95

96

# Create figure with traffic layer

97

fig = gmaps.figure(center=(37.7749, -122.4194), zoom_level=12)

98

traffic_layer = gmaps.traffic_layer()

99

fig.add_layer(traffic_layer)

100

101

# Traffic conditions will be displayed in real-time

102

fig

103

```

104

105

### Traffic with Auto-refresh Disabled

106

107

```python

108

import gmaps

109

110

gmaps.configure(api_key="YOUR_API_KEY")

111

112

# Static traffic snapshot

113

fig = gmaps.figure()

114

traffic_layer = gmaps.traffic_layer(auto_refresh=False)

115

fig.add_layer(traffic_layer)

116

fig

117

```

118

119

### Public Transit Layer

120

121

```python

122

import gmaps

123

124

gmaps.configure(api_key="YOUR_API_KEY")

125

126

# Show public transportation routes

127

fig = gmaps.figure(center=(37.7749, -122.4194), zoom_level=12)

128

transit_layer = gmaps.transit_layer()

129

fig.add_layer(transit_layer)

130

131

# Bus routes, train lines, and subway systems will be displayed

132

fig

133

```

134

135

### Bicycling Routes

136

137

```python

138

import gmaps

139

140

gmaps.configure(api_key="YOUR_API_KEY")

141

142

# Show bicycle-friendly routes

143

fig = gmaps.figure(center=(37.7749, -122.4194), zoom_level=13)

144

bicycling_layer = gmaps.bicycling_layer()

145

fig.add_layer(bicycling_layer)

146

147

# Bike lanes, trails, and cycling routes will be displayed

148

fig

149

```

150

151

### Combined Transportation Layers

152

153

```python

154

import gmaps

155

156

gmaps.configure(api_key="YOUR_API_KEY")

157

158

# Create figure focused on urban area

159

fig = gmaps.figure(

160

center=(37.7749, -122.4194), # San Francisco

161

zoom_level=12

162

)

163

164

# Add traffic information

165

traffic = gmaps.traffic_layer()

166

fig.add_layer(traffic)

167

168

# Add public transit routes

169

transit = gmaps.transit_layer()

170

fig.add_layer(transit)

171

172

# Add bicycling routes

173

bicycling = gmaps.bicycling_layer()

174

fig.add_layer(bicycling)

175

176

# All transportation modes are now visible

177

fig

178

```

179

180

### Transportation with Points of Interest

181

182

```python

183

import gmaps

184

185

gmaps.configure(api_key="YOUR_API_KEY")

186

187

fig = gmaps.figure(center=(37.7749, -122.4194), zoom_level=13)

188

189

# Add transportation layers

190

traffic = gmaps.traffic_layer()

191

transit = gmaps.transit_layer()

192

fig.add_layer(traffic)

193

fig.add_layer(transit)

194

195

# Add markers for transit stations or important locations

196

transit_stations = [

197

(37.7749, -122.4194), # Downtown station

198

(37.7849, -122.4094), # Midtown station

199

(37.7949, -122.3994) # Uptown station

200

]

201

202

markers = gmaps.marker_layer(

203

transit_stations,

204

label=['Downtown', 'Midtown', 'Uptown'],

205

hover_text=['Main Transit Hub', 'Shopping District', 'Residential Area']

206

)

207

fig.add_layer(markers)

208

209

fig

210

```

211

212

### Route Planning with Transportation Context

213

214

```python

215

import gmaps

216

217

gmaps.configure(api_key="YOUR_API_KEY")

218

219

fig = gmaps.figure(center=(37.7749, -122.4194), zoom_level=12)

220

221

# Add transportation context layers

222

traffic = gmaps.traffic_layer()

223

bicycling = gmaps.bicycling_layer()

224

fig.add_layer(traffic)

225

fig.add_layer(bicycling)

226

227

# Add driving route

228

start = (37.7749, -122.4194)

229

end = (37.7849, -122.4094)

230

231

driving_route = gmaps.directions_layer(

232

start, end,

233

travel_mode='DRIVING',

234

stroke_color='blue',

235

stroke_weight=4.0

236

)

237

fig.add_layer(driving_route)

238

239

# Add cycling alternative

240

cycling_route = gmaps.directions_layer(

241

start, end,

242

travel_mode='BICYCLING',

243

stroke_color='green',

244

stroke_weight=3.0

245

)

246

fig.add_layer(cycling_route)

247

248

fig

249

```

250

251

### Transportation Analysis Map

252

253

```python

254

import gmaps

255

import gmaps.datasets

256

257

gmaps.configure(api_key="YOUR_API_KEY")

258

259

fig = gmaps.figure(center=(37.7749, -122.4194), zoom_level=11)

260

261

# Add all transportation layers for comprehensive view

262

traffic = gmaps.traffic_layer()

263

transit = gmaps.transit_layer()

264

bicycling = gmaps.bicycling_layer()

265

266

fig.add_layer(traffic)

267

fig.add_layer(transit)

268

fig.add_layer(bicycling)

269

270

# Add data layer (e.g., taxi pickups to show transportation demand)

271

try:

272

taxi_data = gmaps.datasets.load_dataset_as_df('taxi_rides')

273

pickup_locations = taxi_data[['pickup_latitude', 'pickup_longitude']]

274

275

# Create heatmap of transportation demand

276

demand_heatmap = gmaps.heatmap_layer(

277

pickup_locations,

278

opacity=0.6,

279

max_intensity=10,

280

gradient=['rgba(0,0,255,0)', 'rgba(0,0,255,1)', 'rgba(255,0,0,1)']

281

)

282

fig.add_layer(demand_heatmap)

283

except:

284

# Dataset not available, skip

285

pass

286

287

fig

288

```

289

290

### Real-time Traffic Monitoring

291

292

```python

293

import gmaps

294

import time

295

296

gmaps.configure(api_key="YOUR_API_KEY")

297

298

# Create traffic monitoring setup

299

fig = gmaps.figure(

300

center=(37.7749, -122.4194),

301

zoom_level=12,

302

map_type='ROADMAP'

303

)

304

305

# Traffic layer with auto-refresh enabled

306

traffic = gmaps.traffic_layer(auto_refresh=True)

307

fig.add_layer(traffic)

308

309

# Add key intersections or highways as markers

310

key_locations = [

311

(37.7749, -122.4194), # Downtown

312

(37.7849, -122.4094), # Highway entrance

313

(37.7649, -122.4294) # Bridge approach

314

]

315

316

markers = gmaps.marker_layer(

317

key_locations,

318

label=['DT', 'HW', 'BR'],

319

hover_text=['Downtown Core', 'Highway On-ramp', 'Bridge Approach']

320

)

321

fig.add_layer(markers)

322

323

# Traffic conditions will update automatically

324

fig

325

```

326

327

### Transportation Accessibility Map

328

329

```python

330

import gmaps

331

332

gmaps.configure(api_key="YOUR_API_KEY")

333

334

fig = gmaps.figure(center=(37.7749, -122.4194), zoom_level=12)

335

336

# Show all transportation options

337

transit = gmaps.transit_layer()

338

bicycling = gmaps.bicycling_layer()

339

fig.add_layer(transit)

340

fig.add_layer(bicycling)

341

342

# Add accessible locations

343

accessible_locations = [

344

(37.7749, -122.4194), # Wheelchair accessible station

345

(37.7849, -122.4094), # Bike share station

346

(37.7649, -122.4294) # Park & ride facility

347

]

348

349

accessibility_symbols = gmaps.symbol_layer(

350

accessible_locations,

351

fill_color=['blue', 'green', 'orange'],

352

scale=[5, 4, 4],

353

hover_text=[

354

'Wheelchair Accessible Transit',

355

'Bike Share Station',

356

'Park & Ride Facility'

357

]

358

)

359

fig.add_layer(accessibility_symbols)

360

361

fig

362

```