This is the optimized version of the previously released China Map flash version. The source code is located in googlecode, which provides download and has the following features:
1. Divide administrative regions by province to display detailed information of each province (the content is customized in XML)
2. html display supported
3. Click "Province" to open the webpage link.
4. Support event listening (AS and JavaScript)
Demo address:
Www.richbox.net/files/demo.html
Usage:
Insert the flash into the webpage and configure the corresponding parameters (you need to set the map title and the XML address of the data source. If you want the flash to call back your JavaScript method, see the configuration of the third parameter). swfobject is recommended, for example.Code:
& Lt; Script Type = "text/JavaScript" & gt;
Function eventhandler (e ){
Alert (E. value );
}
VaR S1 = new swfobject(“chinamap.swf "," Ply "," 600 "," 500 "," 10 "," # ffffff ");
S1.addparam ("allowScriptAccess", "always ");
S1.addvariable ("title", "map of China ");
S1.addvariable ("xmlurl", "D. xml ");
S1.addvariable ("jshandler", "eventhandler ");
S1.write ("container ");
& Lt;/script & gt;
Data xml configuration example:
Www.richbox.net/files/d.xml
You can also apply the map to your flash or flex project and listen to the event clicked on the map. Sample Code:
Public class chinamapdemo extends Sprite
{
Public Function chinamapdemo ()
{
Super ();
VaR maploader: loader = new loader ();
Maploader. contentloaderinfo. addeventlistener (event. Complete, init );
Maploader. Load (New urlrequest(“chinamap.swf "));
Addchild (maploader );
}
Private function Init (E: Event): void {
E. currenttarget. content. loaderinfo. Parameters. Title = "map of China ";
VaR demomap: chinamap = E. currenttarget. content as chinamap;
Demomap. addeventlistener (mapevent. itemclick, clickhandler );
}
Private function clickhandler (E: mapevent): void {
Trace (E. value );
}
}
You can download the map file from here:
Code.google.com/p/chinamapforflash/downloads/list
The source code has been provided on Google code. You can modify and use it as needed:
Code.google.com/p/chinamapforflash/source/browse/