【问题标题】:Android Google Maps supporting intersection in MultiPolygonAndroid Google Maps 支持 MultiPolygon 中的交叉点
【发布时间】:2020-11-17 06:49:58
【问题描述】:

我尝试使用单个 Feature 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]
                    ]
                ]
            ]
        }
    }]
}

【问题讨论】:

    标签: android google-maps geojson


    【解决方案1】:

    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]
                        ]
                      ]
                ]
            }
        }]
    }
    

    这种情况下的结果是:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多