zoukankan      html  css  js  c++  java
  • Google earth 画扇形

    //画一个扇形 半径,初始角度,旋转角度,纬度,经度,颜色,姓名
      function DrawShanxing(r, initDegree, Degree, lat, lon, color, name) {
      //创建一个画板可以让你开始画画
      var polygonPlacemark = ge.createPlacemark('');
      polygonPlacemark.setGeometry(ge.createPolygon(''));
      var outer = ge.createLinearRing('');
      polygonPlacemark.getGeometry().setOuterBoundary(outer);
      //设置扇形的颜色
      var style = ge.createStyle(name);
      style.getPolyStyle().getColor().set(color);
      style.getLineStyle().getColor().set('00ffffff');
      polygonPlacemark.setStyleSelector(style);
      //为画板添加事件
      google.earth.addEventListener(polygonPlacemark, 'click', function(event) { try{GAjax.getPlotInfo(name,callback);}catch(err){alert(err.description )} });
      //将画板加入到地图中
      ge.getFeatures().appendChild(polygonPlacemark);
      var coords = outer.getCoordinates();
      var bLat, bLng;
      //画一条边
      bLng = Math.cos(initDegree * 3.1415926 / 180) * r;
      bLat = Math.sin(initDegree * 3.1415926 / 180) * r;
      coords.pushLatLngAlt(lat + bLat, lon + bLng, 0);
      //画顶点
      coords.pushLatLngAlt(lat, lon, 0);
      //画二条边
      bLng = Math.cos(initDegree * 3.1415926 / 180 + Degree * 3.1415926 / 180) * r;
      bLat = Math.sin(initDegree * 3.1415926 / 180 + Degree * 3.1415926 / 180) * r;
      coords.pushLatLngAlt(lat + bLat, lon + bLng, 0);
      for (var i = 15; i > 0; i--) {
      bLng = Math.cos(initDegree *Math.PI / 180 + Degree / 15 * Math.PI / 180 * i) * r;
      bLat = Math.sin(initDegree * Math.PI / 180 + Degree / 15 * Math.PI / 180 * i) * r;
      coords.pushLatLngAlt(lat + bLat, lon + bLng, 0);
      }
      }
    但是这个方法有一个缺陷,就是地球是一个椭圆的,这样用经纬度画出的圆在赤道附近是正常的,但是越到两极越像椭圆。

  • 相关阅读:
    POJ 2253 Prim算法及测试数据
    使用getopt_long解析程序长选项参数
    把Javascript对象序列化后作为参数传输
    JSP工程中的读配置文件方法
    C base64 编码文件
    log的记录
    加权
    项目管理流程和工程管理流程
    从全局眼光看log,异常处理的记录
    证书信任和用户认证
  • 原文地址:https://www.cnblogs.com/googlegis/p/2978833.html
Copyright © 2011-2022 走看看