Mapbox在圆上添加背景图像

问题描述 投票:1回答:1

我正在使用mapbox,我已经聚集了我的数据。现在我想在用户缩放到某个点时显示背景图像(而不是黑色背景!)。

我这样添加:

this.map.addLayer({
    id: "unclustered-point",
    type: "circle",
    source: "earthquakes",
    filter: ["!has", "point_count"],
    paint: {
        "circle-color": "black",
        "circle-radius": 8,
        "circle-stroke-width": 4,
        "circle-stroke-color": "#fff",
    }
});

enter image description here

我正在加载我的geojson:

this.map.addSource("earthquakes", {
    type: "geojson",
    data: this.locations,
    cluster: true,
    clusterMaxZoom: 14, // Max zoom to cluster points on
    clusterRadius: 50 // Radius of each cluster when clustering points (defaults to 50)
});

this.map.addLayer({
    id: "clusters",
    type: "circle",
    source: "earthquakes",
    filter: ["has", "point_count"],
    paint: {
        "circle-color": [
            "step",
            ["get", "point_count"],
            "#002e5b",
            100,
            "#002e5b",
            750,
            "#002e5b"
        ],
        "circle-radius": [
            "step",
            ["get", "point_count"],
            20,
            100,
            30,
            750,
            40
        ],
    }
});

那么我怎样才能获得背景图像而不是黑色背景?

javascript mapbox
1个回答
1
投票

您可以使用在z14处显示的自定义图像添加另一层点。这样,自定义图像将覆盖黑色圆圈。

我建议将黑色圆圈设置得非常小或不存在,这样它就不会与自定义图像冲突。

© www.soinside.com 2019 - 2024. All rights reserved.