<%@ LANGUAGE="VBScript" %> FusionMaps v3 - Database Example <% 'You need to include the following JS file to embed the map using JavaScript 'Embedding using JavaScripts avoids the "Click to Activate..." issue in Internet Explorer 'When you make your own maps, make sure that the path to this JS file is correct. Else, you would get JavaScript errors. %>
 
FusionMaps Demo Application - Database + Drill-down
State-wise population distribution - with respect to total US population. Click on a state to see more details.
<% 'In this example, we show how to connect FusionCharts to a database. 'You can connect to any database. Here, we've shown MS SQL and Access. 'Variables to store XML Data and sum of data 'strXML will be used to store the entire XML document generated dim strXML, sumdata 'Generate the map element 'Create the opening element and add the attributes that we need. strXML = "" 'Define our color range strXML = strXML & "" strXML = strXML & "" strXML = strXML & "" strXML = strXML & "" strXML = strXML & "" strXML = strXML & "" 'Add the starting element for data strXML = strXML & "" 'Fetch all data now 'Initialize sum container sumdata=0 strQuery = "select sum(data) as datap from fcmap_distribution" set rs = Server.CreateObject("ADODB.Recordset") rs.open strQuery,oConn 'Store sum of all data if rs.bof=false then sumdata=rs("datap") end if 'Fetch all Internal id and data sum strQuery = "select Internal_Id, (sum(data) / " & sumdata & ")*100 as datap from fcmap_distribution group by Internal_Id" set rs1 = Server.CreateObject("ADODB.Recordset") rs1.open strQuery,oConn 'Check if we've records to show if rs1.bof=false then 'Iterate through each record do while not rs1.eof strQuery ="select * from fcmap_master where Internal_Id='" + rs1("Internal_Id") + "'" set rs2 = Server.CreateObject("ADODB.Recordset") rs2.open strQuery,oConn 'Generate and also add link to it 'The link will in format Detailed.asp?Internal_Id=Int_Id&map=map_swf.swf - we'll need to URL Encode this link to convert & to %26 (or manually add it as %26 instead of &) strXML = strXML & "" rs1.movenext loop 'Finally, close element and add strXML = strXML & "" 'If needed, you can append additional XML tags here - like STYLE or MARKERS strXML = strXML & "