OpenLayer4——圆形

代码相对简单,提供圆心和半径即可

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
    <link href="ol/ol.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="ol/ol.js" charset="utf-8"></script>
    <script type="text/javascript" src="jquery.js" charset="utf-8"></script>
</head>
<body>
<div id="map" style="width: 100%;height: 100%;background-color: #FFFFF6"></div>
<button id="btn">click</button>
<script>
    var layerVector = new ol.layer.Vector({
        source: new ol.source.Vector()
    });

    var map = new ol.Map({
        layers: [
            new ol.layer.Tile({
                source: new ol.source.OSM(),
            })
            , layerVector
        ],
        target: 'map',
        view: new ol.View({
            center: [12950000, 4860000],
            zoom: 7
        })
    });

    var iconStyle = new ol.style.Style({
        stroke: new ol.style.Stroke({
            color: 'blue',
            lineDash: [4],
            width: 3
        }),
        fill: new ol.style.Fill({
            color: 'rgba(0, 0, 255, 0.5)'
        })
    });

    var pointFeature = new ol.Feature({
        geometry: new ol.geom.Circle([12950000, 4860000], 10000)
    });

    pointFeature.setStyle(iconStyle);
    
    layerVector.getSource().addFeature(pointFeature);
</script>
</body>
</html>
复制代码

 

posted on   疯狂的妞妞  阅读(88)  评论(0编辑  收藏  举报

(评论功能已被禁用)
相关博文:
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
历史上的今天:
2020-03-24 jquery - 设置checkbox单选
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示