|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
|
|
|
|
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class LocationMap extends StatefulWidget {
|
|
|
|
|
|
|
|
final Map<String, String> arguments;
|
|
|
|
|
|
|
|
LocationMap({this.arguments});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _LocationMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _LocationMap extends State<LocationMap> {
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
latLng = BMFCoordinate(double.tryParse(widget.arguments["lat"]), double.tryParse(widget.arguments["lng"]));
|
|
|
|
return Scaffold(
|
|
|
|
appBar: MyAppBar(
|
|
|
|
background: Color(0xFFF7F7F7),
|
|
|
|
title: widget.arguments["storeName"],
|
|
|
|
titleColor: Colors.black87,
|
|
|
|
titleSize: 18.sp,
|
|
|
|
leadingColor: Colors.black,
|
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
child: BMFMapWidget(
|
|
|
|
mapOptions: BMFMapOptions(
|
|
|
|
center: latLng,
|
|
|
|
showZoomControl: false,
|
|
|
|
showMapScaleBar: false,
|
|
|
|
zoomLevel: 12,
|
|
|
|
),
|
|
|
|
onBMFMapCreated: onMapCreated,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
BMFMapController _mapController;
|
|
|
|
BMFCoordinate latLng;
|
|
|
|
BMFMarker bmfMarker;
|
|
|
|
|
|
|
|
onMapCreated(BMFMapController controller) {
|
|
|
|
_mapController = controller;
|
|
|
|
setState(() {
|
|
|
|
_mapController.showUserLocation(true);
|
|
|
|
_mapController.setCustomMapStyle('assets/map_style/chatian.sty', 0);
|
|
|
|
if (bmfMarker == null && _mapController != null) {
|
|
|
|
bmfMarker = BMFMarker(
|
|
|
|
position: latLng,
|
|
|
|
centerOffset: BMFPoint(0.5, 0.7),
|
|
|
|
enabled: false,
|
|
|
|
icon: "assets/image/icon_map_marker.png",
|
|
|
|
draggable: false,
|
|
|
|
);
|
|
|
|
_mapController.addMarker(bmfMarker);
|
|
|
|
}
|
|
|
|
_mapController.updateMapOptions(
|
|
|
|
BMFMapOptions(
|
|
|
|
center: latLng,
|
|
|
|
zoomLevel: 15,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|