Embedding Maps Using <object>/<embed> HTML Tags | ||||||||||||||||||||
FusionMaps XT can also be embedded in web pages using plain HTML and without using FusionCharts JavaScript Class. Note: Only Flash maps can be rendered using <object>/<embed> tags. For this, you need to use the <object>/<embed> HTML tags. This method can be implemented in applications that do not support JavaScript. You can also use this method where the entire map embedding code is fetched using an AJAX request (e.g., ASP.NET UpdatePanel) and the AJAX response should contain the <object>/<embed> tags.
We always recommend that you use FusionCharts JavaScript Class method for embedding the maps in an HTML page. This is the only way to get JavaScript (HTML5) fallback for the maps. When embedding using <object>/<embed> method, only Flash maps will show up. Additionally, the following features will not be supported as they are dependent on the FusionCharts JavaScript Class:
Code examples discussed in this section are present in Download Package > Code > MyFirstMap folder. |
||||||||||||||||||||
HTML embedding with XML data provided as URL | ||||||||||||||||||||
We modify our first sample FirstMap.html and rename it as FirstMap-html-embed-xml-url.html, and copy the following code into it: |
||||||||||||||||||||
<html> <head> <title>My First Map using FusionMaps XT - Using HTML embedding method - XML from URL</title> </head> <body> <object width="750" height="400" id="World" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com /pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" > <param name="movie" value="Maps/FCMap_World.swf" /> <param name="FlashVars" value="&dataURL=Data.xml &chartWidth=750&chartHeight=400 &DOMId=myMapId®isterWithJS=1&debugMode=0"> <param name="quality" value="high" /> <embed src="Maps/FCMap_World.swf" flashVars="&dataURL=Data.xml &chartWidth=750&chartHeight=400 &DOMId=myMapId®isterWithJS=1&debugMode=0" width="750" height="400" name="World" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </body> </html> See it live! |
||||||||||||||||||||
The HTML code in bold is responsible for embedding Flash maps into the HTML page. In the above code, we have done the following:
To render a Flash movie in a browser, the HTML page must contain certain tags for initiating the Flash movie. <object> and <embed> tags are used for this purpose. The <object> tag is recognized by Internet Explorer under Microsoft Windows and the <embed> tag is recognized by other browsers. |
||||||||||||||||||||
HTML embedding using XML data embedded in HTML page | ||||||||||||||||||||
You can also embed the XML in the <object>/<embed> tag itself without depending on the external source. |
||||||||||||||||||||
We modify our first sample FirstMap-html-embed-xml-url.html and rename it as FirstMap-html-embed-xml-embed.html.<html> <head> <title>My First map using FusionMaps XT - Using HTML embedding method - XML from URL</title> </head> <body> <object width="750" height="400" id="World" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/ shockwave/cabs/flash/swflash.cab#version=8,0,0,0" > <param name="movie" value="Maps/FCMap_World.swf" /> <param name="FlashVars" value="&chartWidth=400&chartHeight=300 &DOMId=myMapId®isterWithJS=1&debugMode=0 &dataXML=<map borderColor='005879' fillColor='D7F4FF' numberSuffix='M' includeValueInLabels='1' labelSepChar=':' baseFontSize='9'> <data> <entity id='NA' value='515' /> <entity id='SA' value='373'/> <entity id='AS' value='3875' /> <entity id='EU' value='727' /> <entity id='AF' value='885' /> <entity id='AU' value='32' /> </data> </map>" > <param name="quality" value="high" /> <embed src="Maps/FCMap_World.swf" flashVars="&chartWidth=750&chartHeight=400 &DOMId=myMapId®isterWithJS=1&debugMode=0 &dataXML=<map borderColor='005879' fillColor='D7F4FF' numberSuffix='M' includeValueInLabels='1' labelSepChar=':' baseFontSize='9'> <data> <entity id='NA' value='515' /> <entity id='SA' value='373'/> <entity id='AS' value='3875' /> <entity id='EU' value='727' /> <entity id='AF' value='885' /> <entity id='AU' value='32' /> </data> </map>" width="750" height="400" name="World" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </body> </html> See it live! |
||||||||||||||||||||
As you can note from the bold text in the code above, we have only replaced &dataURL FlashVars variable with &dataXML and to this variable we have passed the map XML data. The resultant map will be the same. Depending on your coding practice, you’d be enclosing the entire XML string either using single or double quotation marks (",""). So, if you are enclosing the entire XML in double quotes, then the XML attributes must be encapsulated in single quotes. Using, single quotes for encapsulation of the entire XML string and also for individual attributes, will lead to a conflict. Conflict arising due to improper use of quotes does not raise an error, but shows an empty space in place of map (or sometimes a JavaScript error). |
||||||||||||||||||||
FusionMaps XT FlashVars details | ||||||||||||||||||||
When using HTML embedding, all variables to the map are passed using FlashVars. The table below lists all such variables supported:
|
||||||||||||||||||||
Limitations of using HTML embed method | ||||||||||||||||||||
There are some limitations of HTML embedding method. Let us get a comprehensive list of the limitations:
|