这篇文章主要介绍mapbox-gl开发中如何画圆,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
function metersToPixelsAtMaxZoom(meters, latitude) {
return meters / 0.075 / Math.cos(latitude * Math.PI / 180)
}
map.addSource("circle_source", {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [110.132, 21.768]
}
}]
}
});
map.addLayer({
"id": "circle_layer",
//类型设置
"type": "circle",
//数据源id设置
"source": "circle_source",
"paint": {
//关键处,设置圆的半径随地图缩放而变化
"circle-radius": {
stops: [
[0, 0],
[20, _pixelRadius]],
base: 2
},
//设置圆的其他属性
"circle-opacity": 0.5,
"circle-stroke-width": 1,
"circle-color": "#00f",
"circle-pitch-alignment": "map"
}
});
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。