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);
      }
      }
    但是这个方法有一个缺陷,就是地球是一个椭圆的,这样用经纬度画出的圆在赤道附近是正常的,但是越到两极越像椭圆。

  • 相关阅读:
    Ajax原生请求及Json基础
    HTML5拖拽练习
    表格单元格间数据的拖拽
    query 获取本身的HTML
    JQuery UI的拖拽功能实现方法小结
    ASP.NET MVC4中使用bootstrip模态框时弹不出的问题
    窗口中各模块的切换效果,使用jquery实现
    窗口模块自适应高度
    新jQuery中attr 与 prop的不同
    用js+css3做一个小球投篮的动画(easing)
  • 原文地址:https://www.cnblogs.com/googlegis/p/2978833.html
Copyright © 2011-2022 走看看