Mapbox-gl加载图层的几种geojson格式数据

382 阅读1分钟

简述

介绍mapbox-gl在加载图层数据时所常用的几种(点、线、面)数据结构

geojson格式数据(点)

{
    type: "FeatureCollection",
        features: [
            {
                type: "Feature",
                properties: {},
                geometry: {
                    type: "Point",
                    coordinates: [116.39104843139647, 39.912287369097186]
                }
            }
        ]
};

geojson格式数据(线)

{
    type: "FeatureCollection",
        features: [
            {
                type: "Feature",
                properties: {},
                geometry: {
                    type: "LineString",
                    coordinates: [
                        [116.38540506362915, 39.91115171447854],
                        [116.3856840133667, 39.90613156632883],
                        [116.3971424102783, 39.906510147702974],
                        [116.39682054519652, 39.9116290208874]
                    ]
                }
            }
        ]
};

geojson格式数据(面)

{
    type: "FeatureCollection",
        features: [
            {
                type: "Feature",
                properties: {},
                geometry: {
                    type: "Polygon",
                    coordinates: [
                        [
                            [116.38752937316895, 39.907859855577165],
                            [116.39570474624634, 39.907859855577165],
                            [116.39570474624634, 39.91083076519556],
                            [116.38752937316895, 39.91083076519556],
                            [116.38752937316895, 39.907859855577165]
                        ]
                    ]
                }
            }
        ]
};