init method
Implementation
@override
Future<String> init(String key) async {
///监听native端返回的数据
methodChannel.setMethodCallHandler((methodCall) async {
debugPrint('TencentMap:${methodCall.method}');
switch (methodCall.method) {
case "flutter_tenc_map_backLocation":
//返回定位信息
Location location = Location();
location.code = methodCall.arguments['code'];
if (location.code == 200) {
location.name = await methodCall.arguments['name'];
location.latitude = await methodCall.arguments['latitude'];
location.longitude = await methodCall.arguments['longitude'];
location.address = await methodCall.arguments['address'];
location.city = await methodCall.arguments['city'];
location.province = await methodCall.arguments['province'];
location.area = await methodCall.arguments['area'];
location.cityCode = await methodCall.arguments['cityCode'];
}
if (locationController.listener.isNotEmpty) {
for (LocationCallBack locationCallBack
in locationController.listener) {
locationCallBack(location);
}
}
break;
case "2":
break;
}
});
return await methodChannel
.invokeMethod("flutter_tenc_map_init", {"key": key});
}