gis 画图形

//pointString是所有点的经纬度得到的字符串,如:"234554,1243,224353,1253",rings的格式为[[234554,1243],[224353,1253]].

function draw(pointString){//画扇形
   var rings = new Array();
   var rs = pointString.split(",");
   for(var i = 0;i<rs.length;i+=2){
  rings.push([Number(rs[i]),Number(rs[i+1])]);
}
   var myPolygon = {"geometry":{"rings":[rings],"spatialReference":{"wkid":4326}},  
"symbol":{"color":[0,0,0,30],"outline":{"color":[0,0,0,255],
"width":1,"type":"esriSLS","style":"esriSLSSolid"}, 
"type":"esriSFS","style":"esriSFSSolid"}

      //定义了该图形的属性,当点击该图形时,可以获取这些值,在一个信息窗口显示
         //(和下面的executeQueryTask(evt)相关联)
 "attributes":{"name":"zou","longitude":"123445","latitude":"234567"}};

}; 
   var gra = new esri.Graphic(myPolygon);
   map.graphics.add(gra);
}

/*
   点击图形时,可以弹出窗口,显示该图形的基本信息,evt返回了点坐标,屏幕坐标,及Graphic里面绑定的一些属性
   在显示信息窗口时,有可能infoWindow无法正常显示,则注意检查样式,不手动添加样式,有可能背景会是可能透明的,
   也可以在body 中添加class="tundra"

  */
  function executeQueryTask(evt){
   if(evt.graphic != undefined){
    map.infoWindow.setTitle("区域详细信息");
    var content = "名 称 :"+evt.graphic.attributes.name+"<br /> 经 度:"+evt.graphic.attributes.longitude;
    map.infoWindow.setContent(content);
    (evt) ? map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint)) : null;
   }
 }

猜你喜欢

转载自zou-jiao.iteye.com/blog/1602190
GIS