115 lines
3.1 KiB
Dart
115 lines
3.1 KiB
Dart
import 'package:amap_map/amap_map.dart';
|
|
import 'package:amap_map_example/widgets/amap_gridview.dart';
|
|
import 'package:amap_map_example/widgets/amap_switch_button.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class GesturesDemoPage extends StatefulWidget {
|
|
GesturesDemoPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_BodyState createState() => _BodyState();
|
|
}
|
|
|
|
class _BodyState extends State<GesturesDemoPage> {
|
|
///是否支持缩放手势
|
|
bool _zoomGesturesEnabled = true;
|
|
|
|
///是否支持滑动手势
|
|
bool _scrollGesturesEnabled = true;
|
|
|
|
///是否支持旋转手势
|
|
bool _rotateGesturesEnabled = true;
|
|
|
|
///是否支持倾斜手势
|
|
bool _tiltGesturesEnabled = true;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final AMapWidget map = AMapWidget(
|
|
rotateGesturesEnabled: _rotateGesturesEnabled,
|
|
scrollGesturesEnabled: _scrollGesturesEnabled,
|
|
tiltGesturesEnabled: _tiltGesturesEnabled,
|
|
zoomGesturesEnabled: _zoomGesturesEnabled,
|
|
);
|
|
|
|
//手势开关
|
|
final List<Widget> gesturesOptions = [
|
|
AMapSwitchButton(
|
|
label: Text('旋转'),
|
|
defaultValue: _rotateGesturesEnabled,
|
|
onSwitchChanged: (value) => {
|
|
setState(() {
|
|
_rotateGesturesEnabled = value;
|
|
})
|
|
},
|
|
),
|
|
AMapSwitchButton(
|
|
label: Text('滑动'),
|
|
defaultValue: _scrollGesturesEnabled,
|
|
onSwitchChanged: (value) => {
|
|
setState(() {
|
|
_scrollGesturesEnabled = value;
|
|
})
|
|
},
|
|
),
|
|
AMapSwitchButton(
|
|
label: Text('倾斜'),
|
|
defaultValue: _tiltGesturesEnabled,
|
|
onSwitchChanged: (value) => {
|
|
setState(() {
|
|
_tiltGesturesEnabled = value;
|
|
})
|
|
},
|
|
),
|
|
AMapSwitchButton(
|
|
label: Text('缩放'),
|
|
defaultValue: _zoomGesturesEnabled,
|
|
onSwitchChanged: (value) => {
|
|
setState(() {
|
|
_zoomGesturesEnabled = value;
|
|
})
|
|
},
|
|
),
|
|
];
|
|
Widget _gesturesOptiosWeidget() {
|
|
return Container(
|
|
padding: EdgeInsets.all(5),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text('手势控制', style: TextStyle(fontWeight: FontWeight.w600)),
|
|
Container(
|
|
padding: EdgeInsets.only(left: 10),
|
|
child: AMapGradView(childrenWidgets: gesturesOptions),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
return Container(
|
|
height: MediaQuery.of(context).size.height,
|
|
width: MediaQuery.of(context).size.width,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Container(
|
|
height: MediaQuery.of(context).size.height * 0.6,
|
|
width: MediaQuery.of(context).size.width,
|
|
child: map,
|
|
),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Container(
|
|
child: _gesturesOptiosWeidget(),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|