如何解决在地图上添加图层/平铺
我正在使用Mapbox在Flutter中进行项目,并且正在寻找一种将图层或图块导入到我的地图的方法,例如(在JS中): https://docs.mapbox.com/mapbox-gl-js/example/adjust-layer-opacity/
到目前为止,我可以显示地图了:
import 'package:mapbox_gl/mapbox_gl.dart';
class MapsDemo extends StatelessWidget {
static const String ACCESS_TOKEN = "...";
MapboxMapController mapController;
static const LatLng SOURCE_LOCATION = LatLng(0.0,0.0);
void _onMapCreated(MapboxMapController controller) {
mapController = controller;
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: MapboxMap(
accessToken: MapsDemo.ACCESS_TOKEN,onMapCreated: _onMapCreated,initialCameraPosition: const CameraPosition(target: SOURCE_LOCATION),));
}
}
void main() {
runApp(MaterialApp(home: MapsDemo()));
}
这是我的完整问题: 有没有一种方法可以获取给定位置的x * x正方形(或圆柱状)图层/块并将其显示在地图上的正确坐标处?
谢谢!
解决方法
最好的方法是按照Akif的要求使用flutter_map: https://pub.dev/packages/flutter_map https://github.com/fleaflet/flutter_map
例如,页面“ overlay_image”完全符合我的要求。
,我不确定mapbox_gl软件包是否支持图层,但是有一个完整的软件包可在地图上查找添加图层。也许您可以检查一下。
https://pub.dev/packages/flutter_map
编辑: MapboxMapController中有两种方法。您可以使用它们。
Future<List> queryRenderedFeatures(
Point<double> point,List<String> layerIds,List<Object> filter) async {
return MapboxGlPlatform.getInstance(_id)
.queryRenderedFeatures(point,layerIds,filter);
}
Future<List> queryRenderedFeaturesInRect(
Rect rect,String filter) async {
return MapboxGlPlatform.getInstance(_id)
.queryRenderedFeaturesInRect(rect,filter);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。