Exporting Maps as PDF or Images > Client-side export > Setting JavaScript callback |
When using FusionMaps Export component, you can configure the component to invoke a callback JavaScript method, when the map has been saved by user. This is useful for tracking whether the exported maps have been saved by your user. By default, the invoked function name is FC_Exported(objRtn). You can, however, call a different function as well by specifying the following in your map XML: <map .. exportCallback='myCallBackFunction' ...> And you then need to define this function in your JavaScript code. However, if you do not define any call back function in your XML, the default callback function FC_Exported is invoked. In either case, an object is passed to the function as FC_Exported(objRtn) or myCallBackFunction(objRtn), which contains the following parameters (returned from Export Component):
Let's quickly see an example code where a callback function has been implemented. In this example, once the user has saved the exported map on his disk (after clicking the Save button for the same), we just show it in a JavaScript alert. |
<html> <body bgcolor="#ffffff"> <!-- We also create a DIV to contain the FusionMaps client-side exporter component --> //Render the exporter SWF in our DIV fcexpDiv </body> |
FC_ExportReady event |
At times, you might want to track the event when the map has finished its capture phase and has passed the data to export component, but user has not saved the image/PDF on his disk. Between initiation of map export and till the time FC_ExportReady event is raised, you might show a waiting message/alert to the user that the map is in processing stage. The syntax of event is FC_ExportReady(DOMId). You can use DOMId (string) as the identifier for each map to check which map has finished processing. The following code explains its usage: |
<script type="text/javascript"> //This event is raised when the map has finished capture phase and passed the data to //Export Component for further processing function FC_ExportReady(DOMId){ alert("The map with DOM ID as " + DOMId + " has finished capture mode. It's now ready to be downloaded"); } </script> |