提交 1c0daea1 authored 作者: 张国庆's avatar 张国庆

修改 计算点距离方法

上级 6431f053
......@@ -32,6 +32,5 @@ android {
}
dependencies {
compileOnly 'com.amap.api:location:5.6.0'
api "com.blankj:utilcodex:1.31.1"
}
}
......@@ -2,10 +2,8 @@ package com.amap.flutter.location;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.amap.api.location.AMapLocationClient;
import com.blankj.utilcode.util.LogUtils;
import java.lang.reflect.Method;
import java.util.Map;
......@@ -106,7 +104,6 @@ public class AMapFlutterLocationPlugin implements FlutterPlugin, MethodCallHandl
double lat2 = (double) argsMap.get("lat2");
double lng2 = (double) argsMap.get("lng2");
double distance = AMapLocationClientImpl.calculateDistance(lat1, lng1, lat2, lng2);
LogUtils.d("calculateDistance", "lat1:" + lat1 + " lng1:" + lng1 + " lat2:" + lat2 + " lng2:" + lng2 + " distance:" + distance);
result.success(distance);
}
......
......@@ -56,8 +56,8 @@ class AMapFlutterLocation {
}
///计算2点之间的距离
Future<double> calculateDistance(double lat1, double lon1, double lat2, double lon2) async {
double result = await _methodChannel.invokeMethod('calculateDistance', {'lat1': lat1, 'lon1': lon1, 'lat2': lat2, 'lon2': lon2});
return result;
var result = await _methodChannel.invokeMethod<double>('calculateDistance', {'lat1': lat1, 'lng1': lon1, 'lat2': lat2, 'lng2': lon2});
return result!;
}
///设置Android和iOS的apikey,建议在weigdet初始化时设置<br>
......@@ -142,7 +142,14 @@ class AMapFlutterLocation {
Map<String, Object> newEvent = Map<String, Object>.of(event);
newEvent.remove('pluginKey');
_receiveStream?.add(newEvent);
print('onLocationChanged: $newEvent');
}
},onError: (Object error) {
print('onLocationChanged error: $error');
_receiveStream?.addError(error);
},onDone: () {
print('onLocationChanged done');
_receiveStream?.close();
});
}
return _receiveStream!.stream;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论