当前位置: 代码迷 >> GIS >> 业务gis 如何让别的开发人员不需要懂gis就可以搞开发? (二)
  详细解决方案

业务gis 如何让别的开发人员不需要懂gis就可以搞开发? (二)

热度:476   发布时间:2016-05-05 06:04:31.0
业务gis 怎么让别的开发人员不需要懂gis就可以搞开发? (二)

  每个业务子系统都要加载flexviewer搭建的gis系统,我们可以共用同一个系统,把要交互的逻辑封装出去,首先把加载flash那段js代码封装起来放到一个自己定义的控制类,这个类暂时叫MapControl,把初始化flash的一个方法定义到里面。

 1 /** 2  * Created with JetBrains WebStorm. 3  * User: haibalai 4  * Date: 15-12-9 5  * Time: 下午3:51 6  * To change this template use File | Settings | File Templates. 7  */ 8  9 var MapControl = function () {10     /**11      * 地图初始化parameter  具体参考Parameter类12      * @type {Parameter}13      */14     this.parameter = new Parameter();15     /**16      * 地图初始化17      */18     this.inlitialize = function () {19 20 21         swfobjhash[this.parameter.div] = this;22         var swfVersionStr = "11.4.0";23         var xiSwfUrlStr = "";24         var flashvars = {};25 26         var params = {};27         params.wmode = "opaque";28         params.quality = "high";29         params.bgcolor = "#ffffff";30         params.allowscriptaccess = "always";31         params.allowfullscreen = "true";32         var attributes = {};33         attributes.id = this.parameter.div;34         attributes.name = this.parameter.div;35         attributes.align = "middle";36         swfobject.embedSWF(37             "http://localhost/mymap/index.swf"  + this.parameter.getUrlString() , this.parameter.div,38             this.parameter.width, this.parameter.height,39             swfVersionStr, xiSwfUrlStr,40             flashvars, params, attributes);41         swfobject.createCSS("#" + this.parameter.div, "display:block;text-align:left;");42     }43 }

  其中Parameter类是我们自定义某些属性的东西,比如地图的长宽,放置div的id,还有系统的别名,flexviewer默认的是config.xml,如果你定制另外一个系统你可以改为config-aaa.xml

之类的。

 

 1 /** 2  * Created with JetBrains WebStorm. 3  * User: haibalai 4  * Date: 15-12-9 5  * Time: 下午3:51 6  * To change this template use File | Settings | File Templates. 7  */ 8      9 var Parameter = function (){10 11     /**12      *图层配置xml13      * @type {string}14      */15     this.config = "";16    17     /**18      * 嵌入flash的div配置19      * @type {string}20      */21     this.div = "";22     /**23      *图形组件的宽24      * @type {string}25      */26     this.width = "";27     /**28      *图形组件的高29      * @type {string}30      */31     this.height = "";32     33 34     this.getUrlString =   function()35     {36         var a =  "?config=" + this.config;37         return a;38     }39 40 41 }

   我们在测试页面html可以这样子

 1 <html> 2 <head> 3     <title>mymap</title> 4     <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 5     <script type="text/javascript" src="http://locahost/mymap/libary/MapTool.js"></script> 6  7 </head> 8  9 10 11 <script type="text/javascript">12 13         var a = new MapControl();14         a.parameter.config = "config.xml";15         a.parameter.div= "flashContent";16         a.parameter.width = "800";17         a.parameter.height = "800";18         a.inlitialize();19     20 </script>21 22 <body>23 24       <div id="flashContent">25 26       </div>27      28 29 </body>30 </html>

  其中MapTool.js是压缩了MacControl.js 和Parameter.js。