android - Android Google Maps 支持 MultiPolygon 中的交叉点
问题描述
我尝试使用单个特征 MultiPolygon 在多边形孔内绘制多边形,如下所示:
但是,当我在 Android 上添加这个 GeoJson 文件时,背景没有得到满足,只有线条被绘制:
当我删除最内部的多边形时,它工作正常:
Google Maps SDK 是否以某种方式支持 MultiPolygons 上的交集?
遵循 GeoJson 文件:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-119.443359, 18.646245],
[-70.751953, 18.646245],
[-70.751953, 46.619261],
[-119.443359, 46.619261],
[-119.443359, 18.646245]
],
[
[-105.732422, 25.324167],
[-105.732422, 39.164141],
[-80.332031, 39.164141],
[-80.332031, 25.324167],
[-105.732422, 25.324167]
],
[
[-96.152344, 29.305561],
[-96.152344, 35.029996],
[-86.132813, 35.029996],
[-86.132813, 29.305561],
[-96.152344, 29.305561]
]
]
]
}
}]
}
解决方案
带孔的GeoJSON "MultiPolygon"
应具有如下结构:
{
"type": "MultiPolygon",
"coordinates": [
[
[<coordinates of first polygone>],
[<coordinates of first hole in first polygone>],
[<coordinates of second hole in first polygone>],
...
[<coordinates of last hole in first polygone>]
],
...
[
[<coordinates of last polygone>],
[<coordinates of first hole in last polygone>],
[<coordinates of second hole in last polygone>],
...
[<coordinates of last hole in last polygone>]
]
]
}
所以,对于你的情况,“最内部的多边形”应该向上移动一级,GeoJSON 应该是这样的:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-119.443359, 18.646245],
[-70.751953, 18.646245],
[-70.751953, 46.619261],
[-119.443359, 46.619261],
[-119.443359, 18.646245]
],
[
[-105.732422, 25.324167],
[-105.732422, 39.164141],
[-80.332031, 39.164141],
[-80.332031, 25.324167],
[-105.732422, 25.324167]
]
],
[
[
[-96.152344, 29.305561],
[-96.152344, 35.029996],
[-86.132813, 35.029996],
[-86.132813, 29.305561],
[-96.152344, 29.305561]
]
]
]
}
}]
}
这种情况下的结果是:
推荐阅读
- reactjs - React - 从excel文件中读取日期
- javascript - BIRT CELL 条件突出显示
- r - xaringan 幻灯片中并排的代码块和输出
- javascript - 在组件外部使用 html 函数返回 [object Object] LitElement
- rest - Axios post call 返回 400 状态码
- swift - NSAttributedString:将(多个)@username[userid] 提及转换为可点击的@username 链接
- python - 使用类别 x 轴绘制 SNS 折线图
- html - Bootstrap 4 Modal 向左移动页面
- xml - Gson 无法序列化 - java.lang.UnsupportedOperationException:尝试序列化。忘记注册类型适配器?
- javascript - stringify match result