Time for action — writing the HTML and the JavaScript code to embed the map in a page
1. Create a new file called
FirstMap.html
under theLearningFusionMaps
folder.2. Write the following code in the page and save it:
<html> <head> <title>My First Map</title> <script language="JavaScript" src="../FusionMaps/FusionMaps.js"></script> </head> <body> <div id="mapdiv" align="center"> FusionMaps. </div> <script type="text/javascript"> var map = new FusionMaps("../FusionMaps/FCMap_USA.swf", "Map1Id", "750", "400", "0", "0"); map.setDataURL("Data.xml"); map.render("mapdiv"); </script> </body> </html>
3. Open the HTML file in a browser to see your first map in action.
What just happened?
You just created your first map. The HTML code is very similar to what we have been using to create charts.
First up, we included the FusionMaps JavaScript class in the same way we included FusionCharts.js
earlier:
<script language...