FusionMaps with ASP.NET (C#) > 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 (C#) 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 > FusionMapCS > 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. |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FormSubmit.aspx.cs" Inherits="FormBased_FormSubmit" %> |
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.cs, present in the same folder. It contains the following code: |
using System; public partial class FormBased_FormSubmit : System.Web.UI.Page // Array data assigned from Context object Items dataArray[0, 0] = "01"; dataArray[0, 1] = Context.Items["AS1"].ToString(); /* //Initialize <map> element // Set colorRange's Maximum and minimum value for displaying color range // Fetch Data from array } // Close <data> element // Add Style on map // Close <map> element // Create Map embedding HTML with data contained in strXML //embed the chart rendered as HTML into Literal - FusionMapsContainer } |
Like the first Example - Using dataXML Method, we call the showMap() function to load and render the map. Let us now discuss the steps involved in this new showMap() function. |
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. |