FusionMaps with ASP > Using dataXML Method |
||||||||||||||||||
FusionMaps can effectively be used with Microsoft ASP to plot data over geographic locations. In this section and the following, we'll show examples on how to plot data on FusionMaps using various methods in ASP. | ||||||||||||||||||
We'll cover the following examples here:
|
||||||||||||||||||
Before proceeding further, we recommend to go through the documentation "How to use FusionMaps" for a better insight. | ||||||||||||||||||
Sample: Using dataXML method | ||||||||||||||||||
|
||||||||||||||||||
The code discussed here is present in Download Package > Code > ASP > BasicExample folder. | ||||||||||||||||||
We will be displaying the population of the continents using FusionMaps in this example. Here is the ASP code that has been used in the example. | ||||||||||||||||||
Creating World Population Map from the data stored in an array | ||||||||||||||||||
BasicMapsArray.asp contains the following code: | ||||||||||||||||||
<%@ Language=VBScript %> 'Store population data 'Create the Map - using strXML as dataXML string; |
||||||||||||||||||
Steps involved in this code | ||||||||||||||||||
First, we included two files:
|
||||||||||||||||||
<!-- #INCLUDE FILE="../Includes/FusionMaps.asp" --> <HTML> <HEAD> ... <script type="text/javascript" language="javascript" src="../JSClass/FusionMaps.js"></script> ... |
||||||||||||||||||
These two files contain functions to embed the map easily. |
||||||||||||||||||
Then we declared an array dataArray to store the population data of 8 continents. This is a 2-dimensional array, where the first column stores the Internal ID for all the continets and the second column stores respective population data. | ||||||||||||||||||
Internal ID is a field which helps to indentify each part of a map uniquely. Please go through the Map Specificaiton Sheet to know the Internal IDs for each map in FusionMaps. | ||||||||||||||||||
dim dataArray(8,2) 'Store population data |
||||||||||||||||||
We defined a variable strXML to store the entire XML data. | ||||||||||||||||||
'Declare strXML to store dataXML of the map dim strXML 'Opening MAP element strXML = "<map borderColor='FFFFFF' fillAlpha='80' showBevel='0' legendPosition='Bottom' >" |
||||||||||||||||||
The following code is used to define the color range for the map entities. Different colors show different range of population. The first range is for the regions where population ranges from 0 to 100000000 and it is shown in Red. The second range is for the regions where population ranges from 100000000 to 500000000 and it is shown in Yellow. The third range is from 500000000 to 1000000000 in dark green and the fourth range is 1000000000 and above in light green color. | ||||||||||||||||||
'Setting Color ranges : 4 color ranges for population ranges strXML = strXML & "<colorRange>" strXML = strXML & "<color minValue='0' maxValue='100000000' displayValue='Population : Below 100 M' color='CC0001' />" strXML = strXML & "<color minValue='100000000' maxValue='500000000' displayValue='Population :100 - 500 M' color='FFD33A' />" strXML = strXML & "<color minValue='500000000' maxValue='1000000000' displayValue='Population :500 - 1000 M' color='069F06' />" strXML = strXML & "<color minValue='1000000000' maxValue='5000000000' displayValue='Population : Above 1000 M' color='ABF456' />" strXML = strXML & "</colorRange>" |
||||||||||||||||||
Next we added the map data in <entity> elements by iterating through the array elements. We used for loop for this. | ||||||||||||||||||
'Opening data element that will store map data strXML = strXML & "<data>" 'Using Data from array for each entity FOR i=1 TO ubound(dataArray) strXML = strXML & "<entity id='" & dataArray(i,1) & "' value='" & dataArray(i,2) & "' />" NEXT 'closing data element strXML = strXML & "</data>" 'closing map element strXML = strXML & "</map>" |
||||||||||||||||||
Finally we called the function renderMap() from FusionMaps.asp file to render the map. | ||||||||||||||||||
'Create the Map - using strXML as dataXML string; Call renderMap("../../Maps/FCMap_World8.swf", "", strXML, "firstMap", 750, 460,0,0) |
||||||||||||||||||
FusionMaps.asp contains the function renderMap(). This helps us create the map simply by passing few parameters in a predefined sequence. The renderMap() function accepts following parameters in the same order as they are presented below: | ||||||||||||||||||
|
||||||||||||||||||
Below is the screenshot of the map used for this example. | ||||||||||||||||||