maptalks实现画三维圆柱

先画一个椭圆,然后3d-extrusion拉高

<!DOCTYPE html>
<html>

<head>
    <title>载入GeoJSON对象数据</title>
    <style type="text/css">
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0px;
        }

        .container {
            width: 100%;
            height: 100%;
        }
    </style>
    <link rel="stylesheet" href="https://maptalks.com/api/maptalks.css" />
    <script type="text/javascript" src="https://maptalks.com/api/maptalks.min.js"></script>
    <script type="text/javascript" src="https://maptalks.com/api/maptalks-gl-layers.js"></script>
    <script type="text/javascript" src="https://maptalks.com/api/dat.gui.min.js"></script>
</head>

<body>
    <button onclick="updateData()">add cyliner data</button>
    <div id="map" class="container" style="background-color: #444444"></div>
    <script>
        const map = new maptalks.Map("map", {
            center: [0, 0],
            zoom: 16,
        });


        const geo = new maptalks.GeoJSONVectorTileLayer("geo", {
            data: {
                type: "FeatureCollection",
                features: [],
            },
        });

        geo.on("dataload", (e) => {
            map.fitExtent(e.extent);
        });

        geo.setStyle({
            style: [{
                filter: true,
                renderPlugin: {
                    dataConfig: {
                        type: "3d-extrusion",
                        altitudeProperty: "height",
                        minHeightProperty: "min_height",
                        altitudeScale: 1,
                        defaultAltitude: 10,
                        topThickness: 0,
                        top: true,
                        side: true,
                    },
                    sceneConfig: {
                        // collision: true,
                        // fading: false,
                        // depthFunc: "always",
                    },
                    type: "lit",
                },
                symbol: {
                    material: {
                        baseColorTexture: null,
                        baseColorFactor: [1, 1, 1, 1],
                        hsv: [0, 0, 0],
                        baseColorIntensity: 1,
                        contrast: 1,
                        outputSRGB: 1,
                        metallicRoughnessTexture: null,
                        roughnessFactor: 1,
                        metallicFactor: 1,
                        normalTexture: null,
                        noiseTexture: null,
                        uvScale: [1, 1],
                        uvOffset: [0, 0],
                        uvRotation: 0,
                        uvOffsetAnim: [0, 0],
                        normalMapFactor: 1,
                        normalMapFlipY: 0,
                        bumpTexture: null,
                        bumpScale: 0.02,
                        clearCoatThickness: 5,
                        clearCoatFactor: 0,
                        clearCoatIor: 1.4,
                        clearCoatRoughnessFactor: 0.04,
                        occlusionTexture: null,
                        emissiveTexture: null,
                        emissiveFactor: [0, 0, 0],
                        emitColorFactor: 1,
                        emitMultiplicative: 0,
                    },
                },
            },],
        });

        const groupLayer = new maptalks.GroupGLLayer("group", [geo]);
        groupLayer.addTo(map);

        function updateData() {
            const coordinates = [];
            for (let i = 0; i < 10; i++) {
                for (let j = 0; j < 10; j++) {
                    coordinates.push([i * 0.1, j * 0.1])
                }
            }
            const circleList = coordinates.map(c => {
                return new maptalks.Circle(c, 2000)
            });
            const features = circleList.map(c => {
                const feature = c.toGeoJSON();
                feature.properties = { height: 3000 + Math.round(Math.random() * 5000) };
                return feature;
            });
            const geojson = {
                type: 'FeatureCollection',
                features
            }
            geo.setData(geojson);
        }
    </script>
</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我就是你的语法糖️

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值