FusionMaps with ASP.NET (C#) > Using dataURL Method |
In this section we will see how to render a map using dataURL method - where the XML data is created in a file other than what we use to generate the map. The page that contains the code to render the map is referred to as Map Container Page and the other one which creates the XML data is called Data Provider Page. Let's look at the codes used in Map Container Page and Data Provider Page one by one. |
Before proceeding further, we recommend to go through the documentation "How to use FusionMaps" for a better insight. |
All code discussed here is present in Download Package > Code > CS_NET > BasicExample folder. |
Map Container Page |
Map Container Page contains the following code. You can view this code in BasicArrayURL.aspx file. |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BasicArrayURL.aspx.cs" Inherits="BasicArrayExample_dataURL" %> <html> |
In the above code, we first include FusionMaps.js file to enable us embed the map using JavaScript. The code behind script generates the map in the litreral control WorldPopulationMap. |
Let us see how code behind script in BasicMapsArrayURL.aspx.cs builds the map XML and renders the map: |
using System; public partial class BasicArrayExample_dataURL : System.Web.UI.Page //embed the chart rendered as HTML into Literal - WorldPopulationMap } |
Steps involved in this code: |
|
Now, let us see the code in Data Provider Page WorldPopulationData.aspx. |
Data Provider Page |
<%@ Page Language="C#" %> // Declare array entity to store world population string[,] dataArray = new string[8, 2]; // Now, we need to convert this data into XML. // Initialize <map> element // Set Color ranges : 4 color ranges for population ranges // Open data element that will store map data // Use Data from array for each entity // close data element // Set Proper output content-type // Just write out the XML data } </script> |
(Here we have used the same code for XML creation that we used in the dataXML example.) |
The Steps involved in this code |
|
Here is the snap of the map: |