简体   繁体   English

如何在 android 应用程序中使用 map 框创建自定义 Air map 视图并绘制多边形

[英]How to create a custom Air map view and draw a polygon using map box in android application

I am using the map box SDK in which I have to set different map types.我正在使用 map 盒子 SDK ,我必须在其中设置不同的 map 类型。 Mostly I have to use an air map view using map box SDK.大多数情况下,我必须使用 map 盒子 SDK 的空气 map 视图。 I want to implement a view like the below image.我想实现如下图所示的视图。

在此处输入图像描述

How would I achieve a view and also how to draw a polygon like this image?我将如何实现视图以及如何绘制像此图像这样的多边形?

Follow https://docs.mapbox.com/android/maps/guides/install/ to set up the Maps SDK and add a basic map to your Android app. Follow https://docs.mapbox.com/android/maps/guides/install/ to set up the Maps SDK and add a basic map to your Android app.

https://docs.mapbox.com/android/maps/examples/draw-a-polygon/ shows how to draw polygons on the map. https://docs.mapbox.com/android/maps/examples/draw-a-polygon/展示了如何在 map 上绘制多边形。 This is if you have the coordinates only on the device.这是如果您只有设备上的坐标。

You could use the Mapbox dataset editor + https://studio.mapbox.com/datasets , to draw the polygons instead.您可以使用Mapbox 数据集编辑器+ https://studio.mapbox.com/datasets来绘制多边形。 Then export the dataset to a vector tileset and then reference the tileset in a Maps SDK VectorSource https://github.com/mapbox/mapbox-android-demo/search?q=VectorSource然后将数据集导出到矢量瓦片集,然后在地图 SDK VectorSource https://github.com/mapbox/mapbox-android-demo/search?q=VectorSource中引用该瓦片集

No matter how you add the data to the map, you'll want to do the additions in a separate method if you'll be switching map styles on the fly.无论您如何将数据添加到 map,如果您要即时切换 map styles,您都需要以单独的方法进行添加。 After the style is successfully changed and loaded, re-add the data/layers.样式更改并加载成功后,重新添加数据/图层。

You could use multiple GeoJSON Polygon objects or a single GeoJSON MultiPolygon您可以使用多个 GeoJSON Polygon对象或单个 GeoJSON MultiPolygon

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM