Since 3.1.0 起地图Flutter插件支持海量点图层(BMFMultiPointOverlay)绘制,用于批量展现坐标点数据。
示例代码如下:
/// 读取海量点String coordinateString = awaitrootBundle.loadString('resoures/10w.txt');// print('coordinateString = ${coordinateString}');/// string -> listList<String> coordStringList = coordinateString.split('');/// 海量点List<BMFMultiPointItem> items = [];for (var i = 0; i < 100000; i++) {List<String> itemString = coordStringList[i].split(',');BMFCoordinate coordinate = BMFCoordinate(double.parse(itemString[1]), double.parse(itemString[0]));BMFMultiPointItem item =BMFMultiPointItem(coordinate: coordinate, title: '${i}');items.add(item);}/// 构造海量点overlay_multiPointOverlay =BMFMultiPointOverlay(items: items, icon: 'resoures/marker_blue.png');await myMapController.addMultiPointOverlay(_multiPointOverlay);
显示效果如图:
上一篇
下一篇
本篇文章对您是否有帮助?