FusionMaps with ASP.NET (VB) > Using Data from Form |
In this section, we will see how to generate a FusionMap using data collected from Form. |
For the sake of demo, let us take the example of a fictional company that wants to plot the world-wide sales report for a particular day on a map. The example first loads a page that has a form to accept data for all the continents. Here, we have put some default data which can be modified as per user's wish. This data will be submitted to another ASP.NET (VB) page. This page will acquire the data and plot it on the map. For the sake of simplicity, we wouldn't do any processing or checking on this data. However, your real life applications might process data before presenting it on the map. |
Before proceeding further, we recommend to go through the section "How to use FusionMaps" for a better insight. |
The code examples contained in this page are present in Download Package > Code > VB_NET > FormBased folder. |
Building the Form |
The form is contained in the Default.aspx page. Shown below is a snapshot: |
This is a very simple form which submits to FormSubmit.aspx which accepts the values and renders the map. Let us have a look at the page - FormSubmit.aspx. |
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="FormSubmit.aspx.vb" Inherits="FormBased_FormSubmit" %> <body> |
Requesting the data and Creating the Map |
The work of requesting the data from submitted form and creating the map is done in FormSubmit.aspx.vb, present in the same folder. It contains the following code: |
Imports InfoSoftGlobal 'FusionMaps.dll in bin folder Partial Class FormBased_FormSubmit ''' <summary> ' Define dataArray Two dimension string Array element. 1st column take ' Array data assigned from Context object Items dataArray(1, 1) = "01" : dataArray(1, 2) = Context.Items("AS1") 'Now that we've the data in variables, we need to convert this into XML. 'Initialize <map> element strXML.Append("<map borderColor='FFFFFF' connectorColor='000000' fillAlpha='70' hoverColor='FFFFFF' showBevel='0'>") ' Set colorRange's Maximum and minimum value for displaying color range Dim i As Integer 'Fatch Data from array ' Create Map embedding HTML with data contained in strXML 'embed the chart rendered as HTML into Literal - FusionMapsContainer End Sub End Class |
Like the first Example - Using dataXML Method, we call generate the XML and render the map. Let us now discuss the steps involved: |
Steps involved in this code |
As you can see in the above code, we're doing the following: |
|
Below is the snapshot of the map that we get here. |