|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:maplibre/maplibre.dart'; |
| 3 | + |
| 4 | +@immutable |
| 5 | +class WidgetLayerPage extends StatefulWidget { |
| 6 | + const WidgetLayerPage({super.key}); |
| 7 | + |
| 8 | + static const location = '/widget-layer'; |
| 9 | + |
| 10 | + @override |
| 11 | + State<WidgetLayerPage> createState() => _WidgetLayerPageState(); |
| 12 | +} |
| 13 | + |
| 14 | +class _WidgetLayerPageState extends State<WidgetLayerPage> { |
| 15 | + @override |
| 16 | + Widget build(BuildContext context) { |
| 17 | + return Scaffold( |
| 18 | + appBar: AppBar(title: const Text('Widget Layer')), |
| 19 | + body: MapLibreMap( |
| 20 | + options: MapOptions( |
| 21 | + initZoom: 3, |
| 22 | + initCenter: Position(0, 0), |
| 23 | + attribution: false, |
| 24 | + nativeCompass: false, |
| 25 | + nativeLogo: false, |
| 26 | + ), |
| 27 | + children: [ |
| 28 | + WidgetLayer( |
| 29 | + markers: [ |
| 30 | + // A 3D marker |
| 31 | + Marker( |
| 32 | + size: const Size.square(50), |
| 33 | + point: Position(-10, 0), |
| 34 | + child: |
| 35 | + const Icon(Icons.location_on, color: Colors.red, size: 50), |
| 36 | + alignment: Alignment.bottomCenter, |
| 37 | + ), |
| 38 | + Marker( |
| 39 | + size: const Size.square(50), |
| 40 | + point: Position(-5, 0), |
| 41 | + child: |
| 42 | + const Icon(Icons.location_on, color: Colors.red, size: 50), |
| 43 | + alignment: Alignment.bottomCenter, |
| 44 | + rotate: true, |
| 45 | + ), |
| 46 | + Marker( |
| 47 | + size: const Size.square(50), |
| 48 | + point: Position(0, 0), |
| 49 | + child: |
| 50 | + const Icon(Icons.location_on, color: Colors.red, size: 50), |
| 51 | + alignment: Alignment.bottomCenter, |
| 52 | + flat: true, |
| 53 | + ), |
| 54 | + Marker( |
| 55 | + size: const Size.square(50), |
| 56 | + point: Position(5, 0), |
| 57 | + child: |
| 58 | + const Icon(Icons.location_on, color: Colors.red, size: 50), |
| 59 | + alignment: Alignment.bottomCenter, |
| 60 | + flat: true, |
| 61 | + rotate: true, |
| 62 | + ), |
| 63 | + ], |
| 64 | + ), |
| 65 | + // display the UI widgets above the widget markers. |
| 66 | + const SourceAttribution(), |
| 67 | + ], |
| 68 | + ), |
| 69 | + ); |
| 70 | + } |
| 71 | +} |
0 commit comments