[Geomoose-users] Auto-refreshing

Brian Fischer bfischer at houstoneng.com
Tue Oct 23 13:41:24 PDT 2012


We have an old GM 2.2 web app that animated through some weather radar.  Here is the code that was used for that.  Not idea if this would work in GM 2.6 or not.

<tool name="animate_layers" title="Weather Radar" type="javascript" selectable="false">
			WeatherLayersAnimator.toggle_animation();
		</tool>

AnimateLayersExtension = new OpenLayers.Class(GeoMOOSE.UX.Extension, {
	current_layer: -1,
	is_animating: false,
	layers_to_animate: [],
	interval_id: -1,
	interval_delay: 1000,

	animate: function() {
		this.is_animating = true;
		/* go to the 0th frame */
		this.current_layer = -1;
		this.next_frame(this);

		/* because of scoping rules with setInterval, we need to pass the class back to the function */
		/* Also, this function variable thing is done because IE doesn't properly implement setInterval */
		var instance = this;
		var my_func = function() {
			instance.next_frame(instance);
		}
		this.interval_id = window.setInterval(my_func, this.interval_delay, this);
	},

	stop_animate: function() {
		clearInterval(this.interval_id);
		this.is_animating = false;
	},

	toggle_animation: function () {
		if(this.is_animating) {
			this.stop_animate();
		} else {
			this.animate();
		}
			
	},

	next_frame: function(instance) {
		instance.current_layer+=1;
		if(instance.current_layer >= instance.layers_to_animate.length) {
			instance.current_layer = 0;
		}

		for(var i = 0; i < instance.layers_to_animate.length; i++) {
			if(i != instance.current_layer) {
				GeoMOOSE.changeLayerVisibility(instance.layers_to_animate[i], false);
			}
		}
		GeoMOOSE.changeLayerVisibility(instance.layers_to_animate[instance.current_layer], true);
	},

	load: function() {
	},

	initialize: function(layers,delay) {
		this.layers_to_animate = layers;
		if(delay) {
			this.interval_delay = delay;
		}
	},
	
	CLASS_NAME: "AnimateLayersExtension"
});

GeoMOOSE.UX.register('AnimateLayersExtension');

Brian Fischer, CFM
Principal | GIS Project Manager 
Houston Engineering, Inc.
O 763.493.4522 | D 763.493.6664 | M 763.229.2734

-----Original Message-----
From: Matej Mailing [mailto:mailing at tam.si] 
Sent: Tuesday, October 23, 2012 1:21 PM
To: Brian Fischer
Cc: GeoMOOSE Users List
Subject: Re: [Geomoose-users] Auto-refreshing

Guys, I am really lost here. Some snippets or pointers in the right direction will be very welcome :-)

Thanks,
Matej

2012/10/22 Matej Mailing <mailing at tam.si>:
> Brian, I can't find anything useful in 2.2. Can you send me some 
> snippet from your working app?
>
> Thanks a lot,
> Matej
>
> 2012/10/18 Brian Fischer <bfischer at houstoneng.com>:
>> I don't believe this was carried over.  You would likely need to write an extension to do this.  There is example code in GM 2.2 I believe.  I have used it once for some weather radar layers.
>>
>> Brian Fischer, CFM
>> Principal | GIS Project Manager
>> Houston Engineering, Inc.
>> O 763.493.4522 | D 763.493.6664 | M 763.229.2734
>>
>>
>> -----Original Message-----
>> From: geomoose-users-bounces at lists.osgeo.org 
>> [mailto:geomoose-users-bounces at lists.osgeo.org] On Behalf Of Matej 
>> Mailing
>> Sent: Wednesday, October 17, 2012 5:02 AM
>> To: GeoMOOSE Users List
>> Subject: [Geomoose-users] Auto-refreshing
>>
>> Hi,
>>
>> if I rembember correctly from 1.X versions that there was a way to turn on and off the auto-refreshing of the specific layers on the specified interval. Is this possible in 2.6?
>>
>> Thanks,
>> Matej
>> _______________________________________________
>> Geomoose-users mailing list
>> Geomoose-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/geomoose-users


More information about the Geomoose-users mailing list