SuperGIS Server API for Flex
SuperGIS Server 3.1 provides abundant API samples to demonstrate how to customize SuperGIS Server websites. Each sample offers the live sample site and codes for you to download and apply to your own website.

Here are essential principles for developers to know before starting customizing the website.
Principles for SuperGIS Server Flex Developers
Before taking the references of this SuperGIS Server Flex Samples, you need to know some principles to make your customization run more smoothly and efficiently. Flex API is good in client side interactive functions regardless of any browsers. As long as your browser supports "Shockwave Flash Object" (ActiveX object), it can run well in any types of browsers.

But it may take you a long time in searching for just some special effect or outlook settings, such as "blur", "dashed line", any kinds of animations. We hope you can find some of the tips in these examples for your flex applications.
1. Query Settings
You have to activate the "Feature Services" for the "Map Service" if you want to implement the query function.

In "SuperGIS Server Manager" > "Publish my map or other GIS Services" > Select one map service in "Published Services" > "config." > Click "Editing" > check on "Use Feature Service" > check on the layer you want to query in "Editable Layers".

It recommends you to close the "sgd" of the published project file while activating the feature service. If it fails to create the "GID" or the attribute table has crashed , stop the "SuperGIS Server Container" service, delete "GID" field and restart it again to re-build the "GID" field.
2. Import anything for developing
Besides SuperGIS Server objects, you also need to import lots of things for different tasks. For example, the following objects are used for drawing graphic on client side:

import flash.display.Graphics;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import mx.collections.ArrayCollection
import mx.containers.Canvas;
import mx.controls.Alert;
import mx.controls.Image;
import mx.events.FlexEvent;
import mx.utils.StringUtil;
import spark.components.BorderContainer;
import spark.components.HGroup;
import spark.components.Label;
import spark.components.Panel;
import spark.components.RadioButton;
import spark.components.RadioButtonGroup;
import spark.components.VGroup;

Some of the object names may conflict with the other object name in flex, for example, "Geometry.Point" and "flash.geom.Point". To avoid mixing them, it is suggested to use the "full" object name rather than shortened one.
3. Flex API website work flow
Flex is a close file type and the only way to show the map is through "Agent.aspx". It can save your time when you start to develop the flex API website with SuperGIS Server API:

1). Add Map Service. Do Not Forget to set up "Feature Services" if your map service is required to be implemented in functions of "Query".

2). Create website. "Ultra" website is enough. It contains "Agent.aspx" in the website folder.

3). Once you finish your flex project, Copy these files to website folder. Create another website to publish it. For example, here are the project files of project "selhtcnt". If you want to publish them, copy all the files in "\bin-debug" to the IIS website. The html page is "selhtcnt.html".



When you put the SuperGIS Server flex map link, remember to put the accessible link, such as:

pLyr.ResourcePath="http://sgs.supergeo.com.tw/uk1/agent.aspx";

When you publish it in server, you have to run the html as:
http://sgs.supergeo.com.tw/<virtual directory name>/selhtcnt.htm
not like this:
http://localhost/<virtual directory name>/selhtcnt.thm
The second one will make it empty in your map.
4. It needs to compile for any changes
In the "\bin-debug" folder, the publish html page contains the "swf" link. It runs the "swf" that is embedded in the html page. When opening the "html" page with NotePad, you can find "*.swf" link inside. That means, if you want to do any changes in the flex website, you need to modify it in "mxml" or ".as" files, then "Compile" it. Actually it can be automatically finished once you "Run" it. Copy the re-compiled files to the server for update.

5. Performance Consideration
It may cause low performance if you put too many graphics on flex. GIS data is a precise data structure but flex client may act very slowly once you put too many geometry graphics on flex. For example, if you draw every country boundary on flex, it certainly acts very slowly when you pan, zoom in / out it. Use "map extent" to filter the data , or simplify your GIS data are both fine for performance consideration.

6. FCode Area
In this sample web site, you can copy the sample code in "Code" section. But remember, some of the samples are required to modify both in "Client Side"(MXML or "*.as" file) and "Server Side"(ex: SGSAgent.cs in ".\App_Code\"). Some "Code" When you copy the "Code" content, do not forget to put the code in the correct files.
Click a map to find out the details of the methods to customize the website.
Mouse over Buffer clip
Drawing tool Information window
Custom browsing button Mouse click