通过 URL 从具有多边形的 mapbox 请求静态图像

Request Static Image from mapbox with polygon via URL

我正在尝试从具有多边形叠加层的 Mapbox 请求地图的静态图像。

我不断收到 422 未知响应。

下面是 url 编码的 geojson: https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/geojson(%7B%22type%22%3A%22FeatureCollection%22%2C%22features%22%3A%5B%7B%22id%22%3A%224c97769717bde5d3ece6aa37ad153a26%22%2C%22type%22%3A%22Feature%22%2C%22geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B-97.35498290052888%2C47.07901887872825%5D%2C%5B-97.34567101592366%2C47.07901887872825%5D%2C%5B-97.34553174426712%2C47.06840297785641%5D%2C%5B-97.35539079875348%2C47.06965221312885%5D%2C%5B-97.36672817535712%2C47.069627161422176%5D%2C%5B-97.36668040297414%2C47.07906677293954%5D%2C%5B-97.35498290052888%2C47.07901887872825%5D%5D%5D%7D%2C%22properties%22%3A%7B%22title%22%3A%22%22%7D%7D%5D%7D)/auto,13/500x300?access_token=MY_MAPBOX_ACCESS_TOKEN

下面是我存储在我的数据库字段中的 geojson 结构,该结构得到 url 编码:

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [
                    [-98.38294, 47.06659],
                    [-98.38322, 47.05229],
                    [-98.36687, 47.05221],
                    [-98.36675, 47.06654],
                    [-98.38294, 47.06659]
                ]
            ]
        },
        "properties": {
            "title": ""
        }
    }]
}

如有任何帮助,我们将不胜感激。

您随此请求收到的错误是一个描述性错误:

{"message":"The auto parameter cannot be used with additional location parameters, bearing, or pitch."}

此请求的问题不是您的覆盖数据,而是您试图在 auto(例如 /auto,13/)之后包含不受支持的其他位置参数这一事实。

如果您从请求中删除 ,13,则图像会按预期呈现:

map with polygon image