周小红
新手
新手
  • UID349
  • 粉丝0
  • 关注0
  • 发帖数1
阅读:4954回复:0

ol6实现椭圆

楼主#
更多 发布于:2020-03-30 16:59
                        
   //绘制椭圆
 var vSource = new ol.source.Vector()
 var vLayer = new ol.layer.Vector({
              source: vSource,
  })
  //radiusMajor椭圆的长半轴、radiusMinor短半轴、center重心和rotation旋转角度
 function genEllipseGeom(radiusMajor, radiusMinor, center, rotation) {
         var circle = new ol.geom.Circle(center, radiusMinor);
         var polygon = new ol.geom.Polygon.fromCircle(circle, 64);
         polygon.scale(radiusMajor / radiusMinor, 1);
         polygon.rotate(rotation, center);
         return polygon;
 }

 var point = ol.proj.transform([106.73,26.59], 'EPSG:4326', 'EPSG:3857');
 var elGeom = genEllipseGeom(600000, 400000, point, Math.PI / 4);
 var ef = new ol.Feature(elGeom);
 vSource.addFeature(ef);
 map.addLayer(vLayer);
游客

返回顶部