Sign in to follow this  
kmorse

Fusion maps - automatic refresh?

Recommended Posts

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

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
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

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
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 by Guest

Share this post


Link to post
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this