Android Google 多边形支持相交的地图
Android Google Maps supporting intersection in 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]
]
]
]
}
}]
}
这种情况下的结果是:
我尝试使用单个特征多多边形在多边形孔内绘制多边形,如下所示:
但是,当我在 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]
]
]
]
}
}]
}
这种情况下的结果是: