kmorse Report post Posted October 29, 2008 I have Fusion maps that will be updated periodically Tuesday night during the U.S. election. Is there any code I could include in the xml file or the html file that would automatically refresh the xml data without the user having to refresh the Web page? Share this post Link to post Share on other sites
Arindam Report post Posted October 31, 2008 Hi, Could you please tell what type of server script technologies are you using (asp, php, aspx etc). you can use javascript timer for automatic refresh. Share this post Link to post Share on other sites
kmorse Report post Posted October 31, 2008 Arindam (10/31/2008)Hi, Could you please tell what type of server script technologies are you using (asp, php, aspx etc). you can use javascript timer for automatic refresh. Hi -- the server we're on has php and python available. Can you tell me how to accomplish the refresh with both backend and frontend (javascript) methods? Share this post Link to post Share on other sites
FusionCharts Support Report post Posted November 1, 2008 Hi, There can be 2 ways: In both cases you would need to use javascript window.setInterval() fucntion to automatically update map using an interval. 1. Using dataURL() method: maop.setDataURL() Pass the dataURL (an php file that generates the XML in text/xml format). Thus the map is automatically updated at client side call and at backend the php script (dtaURL) is executed to generate fresh XML from backend. 2. setDataXML method. You can use this to give smooth look to the map when it is refreshing. In this you would need to use an AJAX framework/or jsut some javascript AJAX code to fetch the XML from the same php script (discussed in point 1) and get as ajax resposeText and then set the map with the new XML using setDataXML() method. Share this post Link to post Share on other sites
kmorse Report post Posted November 2, 2008 (edited) Sudipto Choudhury (11/1/2008)Hi, 1. Using dataURL() method: map.setDataURL() Pass the dataURL (an php file that generates the XML in text/xml format). Thus the map is automatically updated at client side call and at backend the php script (dtaURL) is executed to generate fresh XML from backend. Hi -- here's what we're using to display one of the maps ( on http://www.denverpostplus.com/ElectionMaps/LiveExamples/ele-iframe-home.html): <div id="map1div"> FusionMaps. </div> <script type="text/javascript"> var map1 = new FusionMaps("../Maps/FCMap_Colorado.swf", "Map1Id", "300", "187", "0", "0" ); map1.setDataURL("colo2008.xml" ); map1.setTransparent(true); map1.render("map1div" ); //Attempt to get the refresh working: self.setInterval('mapr(map1)', 5000) function mapr(map) { map.setDataURL("colo2008.xml" ); //map.setTransparent(true); //map.render("map1div" ); } </script> When that runs, it returns a javascript error: Error: mapObj.setDataURL is not a function Source File: http://www.denverpostplus.com/ElectionMaps/JSClass/FusionMaps.js Line: 143 So, I'm wondering: Can you send me some example code of this refresh script done correctly? Either that or could you tell me what I'm doing wrong? Thanks~ Edited November 2, 2008 by Guest Share this post Link to post Share on other sites
Arindam Report post Posted November 2, 2008 Hi, Could you please try with this code? <div id="map1div"> FusionMaps. </div> <script type="text/javascript"> //FusionMaps.js must be include //Register With JS must of set ON ("1") [ RED BELOW] to access the map when updating var map1 = new FusionMaps("../Maps/FCMap_Colorado.swf", "Map1Id", "300", "187", "0", "1" ); map1.setDataURL("colo2008.xml" ); map1.setTransparent(true); map1.render("map1div" ); //Attempt to get the refresh working: window.setInterval(function() { mapr('Map1Id'); }, 5000); function mapr(mapId) { var umap=getMapFromId(mapId); umap.setDataURL("colo2008.xml" ); } </script> Share this post Link to post Share on other sites
kmorse Report post Posted November 3, 2008 Thank you! That works. Share this post Link to post Share on other sites