Using Data URL Method |
In this section we will see how to render a map using Data URL 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 FusionMaps XT works? 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 FusionCharts.js file to enable us embed the map using JavaScript. The code behind script generates the map in the literal 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 map 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 Data String example.) |
The Steps involved in this code |
|
Here is the snap of the map: |