运行灵活网页布局的示例程序

简介:


相信现在使用灵活网页布局的童鞋们越来越多了,也许你注意到了在安装光盘上提供了一下扩展fusion的示例代码,并且在wikihelp文档上提供了如何使用这些例子的方法。可惜这些示例和文档稍微有点过时,需要更新一下,我快速的对前两个例子试了一下,发现一些问题,下面是我的测试过程,也许对你有帮助。现在在忙于devday,后面几个还没时间研究,如果你感兴趣,可以查看相关源代码。

 

By Daniel Du

I am following the “Flexible Web Layouts Examples” on MapServer 2013 wikihelp, and found that this wiki page is a little out-dated. I do not have time to fix them all, so I am just trying to blog how I make some of the examples running. In case you don’t know, the source code of these examples is available on the installation DVD in Samples\FlexibleWebLayoutsSamples.

 

The zip file, FlexibleWebLayoutsExamples.zip, contains source files. Unzip this into theinstallDir\WebServerExtensions\www folder with “Use folder names” selected in WinZip. It installs the following files:

  • fusion\templates\mapguide\examples\*
  • fusion\widgets\Example*.js
  • fusion\widgets\widgetinfo\example*.xml
  • fusion\widgets\example*\*

 

Run Example 1:

Example 1 demos how to create the simplest widget. After installing the code, you will find a new widget name “Example1” available in flexible web layout editor.

1. Create a new flexible web layout in Infrastructure Studio 2013 by c, select a template, I am using slate. Of cause, please make sure MapServer is running first.

2. Assign a map for the Map Tab, I am using the Sheboygan dataset.

image

3. I would like to add my test widget into “Toobar(Main Menu)”, you can also put it into other menu if you’d like to, so I switch to “Toobar(Main Menu)” tab, and click “New” in components available in this layout section:

image

4. You should see a mater type names as “Example1”, if not, try refresh. If it does not appear even after refreshing, then your probably made some mistakes at installation, a common problem is to install the JS/xml files into wrong folder, so please make sure you have same folder structure with the existing widgets. Select “Example1” as master type then click OK button.

image

5. Now I have a new component in the flexible web layout, you can change the ID as you will, I am using the default ID “Example1”:

image

6. Add this component into layout UI, dragging “Example1” into the window left side, a new button is created in main menu toolbar:

image

7. view in browser, and click “Example1” button in main menu toolbar, the “hello word” message shows up:

image

 

Running Example2

Example 1 is pretty simple, I will move next to Example2. Example 2 is a widget that is designed to be called as a command from a menu, it output the information of selected feature. It requires Mozilla® Firefox® 3.6 or higher and the Firebug extension because it writes to the Firebug console.

I am following the same process as example1 to add a new button into main menu toolbar, and browse it in Firefox this time. To run this example, I need to select some features first, then click  the “Example2 ” button.

Oops! I got an error message:

image

Fusion Error: 
WARNING: Exception occurred in AJAX callback. 
Message: theMap.getMapName is not a function 
Location: 
http://localhost/mapserver2013/fusion/widgets/Example2.js (47) 
Response: {"layers":["Parcels"],"extents":{"minx":-87.739602320342,"miny":43.765720296224,"maxx":-87.737804056497,"maxy":43.766709329904},"Parcels":{"propertynames":["RLDESCR1","RTYPE","RACRE","RLOT","RNAME","RLDESCR2","RLDESCR3","RBILAD","RSQFT","RLDESCR4"],"propertyvalues":["Description1","Zone","Acreage","Lot Dimensions","Owner","Description2","Description3","Billing Address","Lot Size (SqFt)","Description4"],"propertytypes":[9,9,9,9,9,9,9,9,7,9],"metadatanames":["dimension","bbox","center","area","length"],"numelements":15,"values":[["BRAND SUBD","RES","0.17","60X124","THIEME, ELAINE M","LOT 11 BLK 3","","2008 N. 25TH ST.","7440",""],["BRAND SUBD","RES","0.25","80X135","RAFFEL, JAMES E","LOT 3 & THE N 20\\' OF LOT 4","BLK 2","2006 N. 24TH ST.","10800",""],["BRAND SUBD","RES","0.25","80X135","FUERST, ROBERT O","N 30\\' OF LOT 23 & S 50\\' OF","LOT 24 BLK 2","2005 N. 25TH ST.","10800",""],["BRAND SUBD","RES","0.17","60X124","TUPPER, ANSEL JR","LOT 12 BLK 3","","2002 N. 25TH ST.","7440",""],["BRAND SUBD","RES","0.22","70X135","YANG, SHOUA PAO","THE S 40\\' OF LOT 4 & THE N","30\\' OF LOT 5 BLK 2","2002 N. 24TH ST.","9450",""],["BRAND SUBD","RES","0.23","75X135","RAKOW, GLEN J.","N 45\\' OF LOT 22 & S 30\\' OF","LOT 23 BLK 2","1919 N. 25TH ST.","10125",""],["BRAND SUBD","RES","0.17","60X124","MATELKO, RICHARD A.","LOT 13 BLK 3","","1918 N. 25TH ST.","7440",""],["BRAND SUBD","RES","0.28","90X135","CASTELLAN, MARY","THE S 30\\' OF LOT 5 & ALL OF","LOT 6 BLK 2","1914 N. 24TH ST.","12150",""],["BRAND SUBD","RES","0.23","75X135","ROERDINK, JAMES P.","LOT 21 & S 15\\' OF LOT 22 BLK","2","1913 N. 25TH ST.","10125",""],["BRAND SUBD","RES","0.22","75X125","PIONTKOWSKI, JOHN A.","S 45\\' OF LOT 15 & N 30\\' OF","LOT 16 BLK 3","1904 N. 25TH ST.","9375",""],["BRAND SUBD","RES","0.19","60X135","HAMER, MARGARET J","LOT 19 BLK 2","","1849 N. 25TH ST.","8100",""],["BRAND SUBD","RES","0.19","60X135","BOPHA, DAVID & MANYP","LOT 8 BLK 2","","1850 N. 24TH ST.","8100",""],["BRAND SUBD","RES","0.22","75X125","HORWITZ, DONALD","LOT 14 & THE N 15\\' OF LOT 15","BLK 3","1912 N. 25TH ST.","9375",""],["BRAND SUBD","RES","0.19","60X135","ABRAHAM, ROBERT A.","LOT 20 BLK 2","","1905 N. 25TH ST.","8100",""],["BRAND SUBD","RES","0.19","60X135","LAMB, DANIEL F","LOT 7 BLK 2","","1906 N. 24TH ST.","8100",""]],"metadata":[["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""],["","","","",""]]}}

 

You may get scared with such a long error message at first glance, To be frankly, I got a high blood pressure as well when I saw this first time Smile. But let’s clam down and looked into the error again, I highlighted and marked it as bold. Message: theMap.getMapName is not a function , it seems that theMap object does not have a method “getMapName”. So I looked into the source code of map widget, which is C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www\fusion\lib\Map.js by default. Yes, that’s the reason, getMapName method is missing, so I went ahead to add this method as below, around line 1247:

 

//Added by Daniel 2012/11/01 
getMapName: function() { 
    return this.aMaps[0]._sMapname; 
},

 

It is pretty simple one. 

As I said earlier, I am using Slate as my template when testing these examples, and the slate template is referring to a compressed single file of fusion library. To apply my changes, I need to edit the JavaScript reference in C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www\fusion\templates\mapguide\slate\index.html, please refer to this blog post for more information about this:

<script type="text/javascript" src="../../../lib/fusion.js"></script>

Now let’s refresh the page and test again, the information about the selection has been written to the firebug console:

image

Look at it closer:

image

 

Okay, I would like to stop here, you may want to keep trying the following examples, and it may not work as expected, but since all source code of fusion is released with the product(C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www\fusion), you can debug it yourself with help of Firebug, as introduced in this post. Hopefully you can work them out yourself.

 

Good luck!

作者: 峻祁连
邮箱:junqilian@163.com 
出处: http://junqilian.cnblogs.com 
转载请保留此信息。



本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2012/11/21/2780108.html ,如需转载请自行联系原作者
相关文章
|
6月前
|
容器 C# 开发者
XAML语言大揭秘:WPF标记的魅力所在,让你轻松实现界面与逻辑分离,告别复杂代码!
【8月更文挑战第31天】XAML提供了一种直观且易于维护的界面设计方式,使得开发者可以专注于逻辑和业务代码的编写,而无需关心界面细节。通过数据绑定、布局管理和动画效果等特性,XAML可以实现丰富的界面交互和视觉效果。在实际开发过程中,开发者应根据具体需求选择合适的技术方案,以确保应用程序能够满足用户的需求。希望本文的内容能够帮助您在WPF应用程序开发中更好地利用XAML语言。
70 0
|
7月前
|
小程序
跨端技术问题之页面或组件样式在小程序、小程序插件和小程序分包中有什么差异
跨端技术问题之页面或组件样式在小程序、小程序插件和小程序分包中有什么差异
|
9月前
|
前端开发 JavaScript API
极简运行Vue打包文件:让你的网页快速启动,高效展现!
欢迎来到前端入门之旅!这个专栏是为那些对Web开发感兴趣、刚刚开始学习前端的读者们打造的。无论你是初学者还是有一些基础的开发者,我们都会在这里为你提供一个系统而又亲切的学习平台。我们以问答形式更新,为大家呈现精选的前端知识点和最佳实践。通过深入浅出的解释概念,并提供实际案例和练习,让你逐步建立起一个扎实的基础。无论是HTML、CSS、JavaScript还是最新的前端框架和工具,我们都将为你提供丰富的内容和实用技巧,帮助你更好地理解并运用前端开发中的各种技术。
|
程序员 Python
Python Qt GUI设计:窗口之间数据传递(拓展篇—5)
在开发程序时,如果这个程序只有一个窗口,则应该关心这个窗口里面的各个控件之间是如何传递数据的。如果这个程序有多个窗口,那么还应该关心不同的窗口之间是如何传递数据的。 本篇博文首先给出一个例子,说明在一个窗口中不同控件之间的数据是如何传递的。对于多窗口的情况,一般有两种解决方法:一种是主窗口获取子窗口中控件的属性,另一种是通过信号与槽机制,一般是子窗口通过发射信号的形式传递数据,主窗口的槽函数获取这些数据。
|
Web App开发 前端开发 JavaScript
前端必须熟悉的几种布局方式
本章主要是回顾Flex使用 和 一些常用布局的写法。
181 0
|
数据可视化 API Python
Python Qt GUI设计:窗口布局管理方法【强化】(基础篇—6)
Python Qt GUI设计:窗口布局管理方法【强化】(基础篇—6)
Python Qt GUI设计:窗口布局管理方法【强化】(基础篇—6)
|
Python 容器
Python Qt GUI设计:如何调整组件布局比例?(拓展篇—1)
Python Qt GUI设计:如何调整组件布局比例?(拓展篇—1)
Python Qt GUI设计:如何调整组件布局比例?(拓展篇—1)
|
Python 容器
Python Qt GUI设计:窗口布局管理方法【基础】(基础篇—5)
Python Qt GUI设计:窗口布局管理方法【基础】(基础篇—5)
Python Qt GUI设计:窗口布局管理方法【基础】(基础篇—5)
|
XML 程序员 C语言
Qt编写控件属性设计器1-加载插件
一、前言 加载插件是整个属性设计器的第一步要打通的功能,插件中的控件都加载不了,后面就别搞别玩下去了没法玩的,要从一个动态库中加载出来控件,肯定需要用到反射机制,以前做.NET开发的时候就觉得反射这个东西相当强大,居然可以读取DLL加载出来控件,现在用Qt,发现Qt也有反射机制,也许这东东可能各大.
1046 0