|
@@ -62,13 +62,13 @@ class _MapChoicePointState extends State<MyHomePage>
|
|
|
setlatlng() {
|
|
|
var helper = LocationHelper();
|
|
|
|
|
|
- helper
|
|
|
- .getLocation((String lat, String lng, String cityName, {provinceName}) {
|
|
|
+ helper.getLocation((lat, lng, cityName, {address, provinceName}) {
|
|
|
if (lat != null && lng != null) {
|
|
|
helper.stopGettingLocation();
|
|
|
}
|
|
|
var latLng = LatLng(double.parse(lat), double.parse(lng));
|
|
|
_amapController?.setCenterCoordinate(latLng);
|
|
|
+ showTost(latLng);
|
|
|
// setState(() {});
|
|
|
// NavigatorUtils.goBackWithParams(context, "$lng,$lat");
|
|
|
});
|
|
@@ -287,86 +287,7 @@ class _MapChoicePointState extends State<MyHomePage>
|
|
|
print("//////////////");
|
|
|
print(coord.latitude);
|
|
|
print(coord.longitude);
|
|
|
- String address;
|
|
|
- String addressM;
|
|
|
-
|
|
|
- /// 逆地理编码(坐标转地址)
|
|
|
- ReGeocode reGeocodeList = await AmapSearch.searchReGeocode(
|
|
|
- coord,
|
|
|
- );
|
|
|
-
|
|
|
- // print(await reGeocodeList.toFutureString());
|
|
|
- // print(await reGeocodeList.provinceName);
|
|
|
-
|
|
|
- // print(await reGeocodeList.cityName);
|
|
|
- // print(await reGeocodeList.districtName);
|
|
|
-
|
|
|
- print("reGeocodeList.provinceName=================");
|
|
|
- addressM = (await reGeocodeList.provinceName) +
|
|
|
- (await reGeocodeList.cityName) +
|
|
|
- (await reGeocodeList.districtName);
|
|
|
- address = await reGeocodeList.formatAddress;
|
|
|
- print(address);
|
|
|
- print(address +
|
|
|
- "," +
|
|
|
- coord.latitude.toString() +
|
|
|
- "," +
|
|
|
- coord.longitude.toString());
|
|
|
- if (_amapController != null) {
|
|
|
- //移除原来的点
|
|
|
- if (_markerSelect != null) {
|
|
|
- _markerSelect.remove();
|
|
|
- }
|
|
|
- if (_markerSeached != null) {
|
|
|
- _markerSeached.remove();
|
|
|
- }
|
|
|
- _markerSeached = await _amapController.addMarker(MarkerOption(
|
|
|
- latLng: coord,
|
|
|
- ));
|
|
|
- //画上新的点
|
|
|
- // _markerSelect = await _amapController.addMarker(MarkerOption(
|
|
|
- // latLng: coord,
|
|
|
- // iconUri: _imgUri,
|
|
|
- // imageConfig: createLocalImageConfiguration(context),
|
|
|
- // width: 64,
|
|
|
- // height: 64,
|
|
|
- // anchorV: 0.7,
|
|
|
- // anchorU: 0.5));
|
|
|
- // widget.onChoicePoint(coord);
|
|
|
- showAlert(
|
|
|
- navigatorKey.currentState.overlay.context,
|
|
|
- "提示",
|
|
|
- "出诊地址为: $address",
|
|
|
- "确定",
|
|
|
- () {
|
|
|
- Navigator.of(navigatorKey.currentState.overlay.context)
|
|
|
- ..pop();
|
|
|
- if (context != null) {
|
|
|
- Navigator.of(navigatorKey.currentState.overlay.context)
|
|
|
- ..pop();
|
|
|
- }
|
|
|
-
|
|
|
- // setExtAddress(address+","+coord.latitude.toString()+","+coord.longitude.toString());
|
|
|
- String setAddress = address +
|
|
|
- "," +
|
|
|
- coord.latitude.toString() +
|
|
|
- "," +
|
|
|
- coord.longitude.toString();
|
|
|
- String setAddressMaster = addressM;
|
|
|
- if (widget.type == "1") {
|
|
|
- FastNotification.push("set_address", setAddress);
|
|
|
- } else if (widget.type == "2") {
|
|
|
- FastNotification.push(
|
|
|
- "set_address_master", setAddressMaster);
|
|
|
- }
|
|
|
- },
|
|
|
- txt2: "取消",
|
|
|
- onPre2: () {
|
|
|
- Navigator.of(navigatorKey.currentState.overlay.context)
|
|
|
- ..pop();
|
|
|
- },
|
|
|
- );
|
|
|
- }
|
|
|
+ showTost(coord);
|
|
|
},
|
|
|
onMapMoveStart: (MapMove move) {},
|
|
|
// 地图创建完成回调 (可选)
|
|
@@ -418,6 +339,69 @@ class _MapChoicePointState extends State<MyHomePage>
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ showTost(coord) async {
|
|
|
+ String address;
|
|
|
+ String addressM;
|
|
|
+
|
|
|
+ /// 逆地理编码(坐标转地址)
|
|
|
+ ReGeocode reGeocodeList = await AmapSearch.searchReGeocode(
|
|
|
+ coord,
|
|
|
+ );
|
|
|
+
|
|
|
+ print("reGeocodeList.provinceName=================");
|
|
|
+ addressM = (await reGeocodeList.provinceName) +
|
|
|
+ (await reGeocodeList.cityName) +
|
|
|
+ (await reGeocodeList.districtName);
|
|
|
+ address = await reGeocodeList.formatAddress;
|
|
|
+ print(address);
|
|
|
+ print(address +
|
|
|
+ "," +
|
|
|
+ coord.latitude.toString() +
|
|
|
+ "," +
|
|
|
+ coord.longitude.toString());
|
|
|
+ if (_amapController != null) {
|
|
|
+ //移除原来的点
|
|
|
+ if (_markerSelect != null) {
|
|
|
+ _markerSelect.remove();
|
|
|
+ }
|
|
|
+ if (_markerSeached != null) {
|
|
|
+ _markerSeached.remove();
|
|
|
+ }
|
|
|
+ _markerSeached = await _amapController.addMarker(MarkerOption(
|
|
|
+ latLng: coord,
|
|
|
+ ));
|
|
|
+
|
|
|
+ showAlert(
|
|
|
+ navigatorKey.currentState.overlay.context,
|
|
|
+ "提示",
|
|
|
+ "出诊地址为: $address",
|
|
|
+ "确定",
|
|
|
+ () {
|
|
|
+ Navigator.of(navigatorKey.currentState.overlay.context)..pop();
|
|
|
+ if (context != null) {
|
|
|
+ Navigator.of(navigatorKey.currentState.overlay.context)..pop();
|
|
|
+ }
|
|
|
+
|
|
|
+ // setExtAddress(address+","+coord.latitude.toString()+","+coord.longitude.toString());
|
|
|
+ String setAddress = address +
|
|
|
+ "," +
|
|
|
+ coord.latitude.toString() +
|
|
|
+ "," +
|
|
|
+ coord.longitude.toString();
|
|
|
+ String setAddressMaster = addressM;
|
|
|
+ if (widget.type == "1") {
|
|
|
+ FastNotification.push("set_address", setAddress);
|
|
|
+ } else if (widget.type == "2") {
|
|
|
+ FastNotification.push("set_address_master", setAddressMaster);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ txt2: "取消",
|
|
|
+ onPre2: () {
|
|
|
+ Navigator.of(navigatorKey.currentState.overlay.context)..pop();
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
// void setExtAddress (String str)async{
|
|
|
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
// prefs.setString("extAddress",str);
|