arcgis api for flex 开发入门(九)webservices 的使用
flex 本身对webservices有着良好的支持,我们可以调用互联网上的各种
webservices来结合esri 的map 做出自己想要的东西
我们就拿现在比较流行的天气预报来做例子,我们要实现的目标就是通过
webservices查询到武汉的天气情况,然后使用infowindow 显示到esri 的map上
,在讲解过程中,我们会重点解释infowindow 的用法。
现在提供天气预报的webservices很多,我们选用
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?
来进行天气的查询。
那么,在flex中如何使用webservices呢?
只要使用 <mx:WebService>标签创建一个WebService就可以了,id唯一标识这个
webservice,wsdl指向提供webservice的地址。
<mx:WebService ;
             var img1 :Image = new Image;
             img1.load(path+arrC.getItemAt(8).toString());
             hbox.addChild(img1);
             var img2 :Image = new Image;
             img2.load(path+arrC.getItemAt(9).toString());
             hbox.addChild(img2);
            
           
             var txtTem :Text = new Text();
             txtTem.text =  arrC.getItemAt(5).toString();
             var txtWea :Text = new Text();
             txtWea.text =  arrC.getItemAt(6).toString();
             var txtWind :Text = new Text();
             txtWind.text =  arrC.getItemAt(7).toString();
             vbox.addChild(txtTem);
             vbox.addChild(txtWea);
             vbox.addChild(txtWind);
             vbox2.addChild(hbox);
             vbox2.addChild(vbox);
             canvas.addChild(vbox2);
            
             myMap.infoWindow.content = canvas;
             var mapPnt2:MapPoint = new MapPoint
(114.1547298,30.5127677);
             myMap.infoWindow.show(mapPnt2);
             myMap.centerAt(mapPnt2);                  
   
           }
          }
设置infoWindow有两点需要注意,一是infoWindow不需要自己new一个,只需要把
你要显示的内容赋值给myMap.infoWindow,二是显示的时候只需要调用
myMap.infoWindow.show(mapPnt2);就可以了,把你想显示的位置告诉他。
完整代码:

 

 

>

原文地址:http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=35702&extra=page%3D3%26amp%3Borderby%3Ddateline

相关文章:

  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-01-28
  • 2021-06-03
  • 2021-10-07
  • 2021-07-26
  • 2022-12-23
相关资源
相似解决方案