OpenLayers map.AfterDraw event

8 messages Options
Embed this post
Permalink
geojoe

OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink

I would like to save the map extent to cookies so I can use it on a page refresh.

Is there an AfterDraw event and if not how do I create it so it will fire the function below?

function saveMapExtentCookies() {
        var bounds = map.getExtent();
        var date = new Date();
        var days = 1;

        alert(bounds.Left);

        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
        document.cookie = "'mapExtentLeft'="  +bounds.Left    +expires;
        document.cookie = "'mapExtentBottom'="+bounds.Bottom +expires;
        document.cookie = "'mapExtentRight'=" +bounds.Right  +expires;
        document.cookie = "'mapExtentTop'="   +bounds.Top    +expires;
}


Thanks
Andreas Hocevar-2

Re: OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink
Hi,

maybe you want to use the map's moveend event?

Regards,
Andreas.

geojoe wrote:

> I would like to save the map extent to cookies so I can use it on a page
> refresh.
>
> Is there an AfterDraw event and if not how do I create it so it will fire
> the function below?
>
> function saveMapExtentCookies() {
> var bounds = map.getExtent();
> var date = new Date();
> var days = 1;
>
> alert(bounds.Left);
>
>         date.setTime(date.getTime()+(days*24*60*60*1000));
>         var expires = "; expires="+date.toGMTString();
> document.cookie = "'mapExtentLeft'="  +bounds.Left    +expires;
> document.cookie = "'mapExtentBottom'="+bounds.Bottom +expires;
> document.cookie = "'mapExtentRight'=" +bounds.Right  +expires;
> document.cookie = "'mapExtentTop'="   +bounds.Top    +expires;
> }
>
>
> Thanks
>  


--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
geojoe

Re: OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink
Andreas,

This seems to work except when I refresh the page I get the extent of the map before the current extent.

Is there another event that fires after the map draw that I could use?

I just started delving into OpenLayers this week.  Where can I find a list of all of the map events like "moveend"?  I haven't been able to find them in one place @ http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html

Thanks,
Joe




Christopher Schmidt-2

Re: OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink
On Fri, Nov 06, 2009 at 05:05:43AM -0800, geojoe wrote:

>
> Andreas,
>
> This seems to work except when I refresh the page I get the extent of the
> map before the current extent.
>
> Is there another event that fires after the map draw that I could use?
>
> I just started delving into OpenLayers this week.  Where can I find a list
> of all of the map events like "moveend"?  I haven't been able to find them
> in one place @ http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html

http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.EVENT_TYPES

> Thanks,
> Joe
>
>
>
>
>
> --
> View this message in context: http://n2.nabble.com/OpenLayers-map-AfterDraw-event-tp3955274p3958625.html
> Sent from the OpenLayers Dev mailing list archive at Nabble.com.
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://openlayers.org/mailman/listinfo/dev

--
Christopher Schmidt
MetaCarta
_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
geojoe

Re: OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink
Christopher,

Thanks for the link.

As to my other problem - I also save the zoom level on the "moveend" event and call "map.zoomTo(zoomLevel);" at the end of the map Init() function.  This seems to have solved the problem.

Thanks again Christopher and Andreas for helping an infant in OpenLayers.

Joe


Christopher Schmidt-2 wrote:
On Fri, Nov 06, 2009 at 05:05:43AM -0800, geojoe wrote:
>
> Andreas,
>
> This seems to work except when I refresh the page I get the extent of the
> map before the current extent.
>
> Is there another event that fires after the map draw that I could use?
>
> I just started delving into OpenLayers this week.  Where can I find a list
> of all of the map events like "moveend"?  I haven't been able to find them
> in one place @ http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html

http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.EVENT_TYPES

> Thanks,
> Joe
>
>
>
>
>
> --
> View this message in context: http://n2.nabble.com/OpenLayers-map-AfterDraw-event-tp3955274p3958625.html
> Sent from the OpenLayers Dev mailing list archive at Nabble.com.
> _______________________________________________
> Dev mailing list
> Dev@openlayers.org
> http://openlayers.org/mailman/listinfo/dev

--
Christopher Schmidt
MetaCarta
_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev
geojoe

Re: OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink
The logic I used for the page refresh didn't really work.

It seems that when I use the saved extent in the map Init() function and call "map.zoomToExtent( lastExtent );" this redraws the last extent properly but I can no longer zoom out. This command seems to reset the map maxExtent so when I ZoomToMaxExtent() I'm stuck with the current extent.

-------------

I am updating a postgres database by adding or moving points and displaying two views into that database. I've been trying to display the new data by doing an HTML page refresh preserving the last extent.

What I would really like is to have a redraw map control that re-reads the database views to get the updated positions and refreshes the map using the current extent.

Does a refresh or redraw map control exist that does this? Again, I haven't been able to find one.

Thanks,
Joe


geojoe wrote:
Christopher,

Thanks for the link.

As to my other problem - I also save the zoom level on the "moveend" event and call "map.zoomTo(zoomLevel);" at the end of the map Init() function.  This seems to have solved the problem.

Thanks again Christopher and Andreas for helping an infant in OpenLayers.

Joe


Christopher Schmidt-2 wrote:
On Fri, Nov 06, 2009 at 05:05:43AM -0800, geojoe wrote:
>
> Andreas,
>
> This seems to work except when I refresh the page I get the extent of the
> map before the current extent.
>
> Is there another event that fires after the map draw that I could use?
>
> I just started delving into OpenLayers this week.  Where can I find a list
> of all of the map events like "moveend"?  I haven't been able to find them
> in one place @ http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html

http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.EVENT_TYPES

> Thanks,
> Joe
>
>
>
>
>
> --
> View this message in context: http://n2.nabble.com/OpenLayers-map-AfterDraw-event-tp3955274p3958625.html
> Sent from the OpenLayers Dev mailing list archive at Nabble.com.
> _______________________________________________
> Dev mailing list
> Dev@openlayers.org
> http://openlayers.org/mailman/listinfo/dev

--
Christopher Schmidt
MetaCarta
_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev
Kris Geusebroek

Re: OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink
Hi Joe,

During foss4g in sydney i wrote a refresh strategy, the patch is
attached to ticket 2317 and will be reviewed shortly. In the mean time
feel free to use it and if you have suggestion for improvements don't
hesitate to mail me.

The strategy can be applied to a vector layer, in the constructor you
supply the amount of milliseconds a refresh is needed and the
layer.refresh method is called every so many milliseconds, if the
visibility is false no refresh is done until the visibility changes
again.

Hope this is of use to you.

Cheers Kris

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of geojoe
Sent: Friday, November 06, 2009 9:13 PM
To: [hidden email]
Subject: Re: [OpenLayers-Dev] OpenLayers map.AfterDraw event


The logic I used for the page refresh didn't really work.

It seems that when I use the saved extent in the map Init() function and
call "map.zoomToExtent( lastExtent );" this redraws the last extent
properly
but I can no longer zoom out. This command seems to reset the map
maxExtent
so when I ZoomToMaxExtent() I'm stuck with the current extent.

-------------

I am updating a postgres database by adding or moving points and
displaying
two views into that database. I've been trying to display the new data
by
doing an HTML page refresh preserving the last extent.

What I would really like is to have a redraw map control that re-reads
the
database views to get the updated positions and refreshes the map using
the
current extent.

Does a refresh or redraw map control exist that does this? Again, I
haven't
been able to find one.

Thanks,
Joe



geojoe wrote:
>
> Christopher,
>
> Thanks for the link.
>
> As to my other problem - I also save the zoom level on the "moveend"
event
> and call "map.zoomTo(zoomLevel);" at the end of the map Init()
function.
> This seems to have solved the problem.
>
> Thanks again Christopher and Andreas for helping an infant in
OpenLayers.

>
> Joe
>
>
>
> Christopher Schmidt-2 wrote:
>>
>> On Fri, Nov 06, 2009 at 05:05:43AM -0800, geojoe wrote:
>>>
>>> Andreas,
>>>
>>> This seems to work except when I refresh the page I get the extent
of
>>> the
>>> map before the current extent.
>>>
>>> Is there another event that fires after the map draw that I could
use?
>>>
>>> I just started delving into OpenLayers this week.  Where can I find
a
>>> list
>>> of all of the map events like "moveend"?  I haven't been able to
find
>>> them
>>> in one place @
>>> http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html
>>
>>
http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.M
ap.EVENT_TYPES

>>
>>> Thanks,
>>> Joe
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>
http://n2.nabble.com/OpenLayers-map-AfterDraw-event-tp3955274p3958625.ht
ml

>>> Sent from the OpenLayers Dev mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://openlayers.org/mailman/listinfo/dev
>>
>> --
>> Christopher Schmidt
>> MetaCarta
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://openlayers.org/mailman/listinfo/dev
>>
>>
>
>

--
View this message in context:
http://n2.nabble.com/OpenLayers-map-AfterDraw-event-tp3955274p3961041.ht
ml
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
_______________________________________________
Dev mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/dev
geojoe

Re: OpenLayers map.AfterDraw event

Reply Threaded More More options
Print post
Permalink

Being very new to OpenLayers I finally figured out how to add a control button to the map.  I still have to figure out how to get the indices of the layers using the layer names rather than hard coding them.

//Refresh Map control
var refreshcon = new OpenLayers.Control.Button({title: "Refreshes the Biomass Sites.", displayClass: "olControlRefreshMap", trigger: myRefreshMap});


function myRefreshMap(){
   if( isBiomass ) {
      map.layers[2].redraw(true);
      map.layers[3].redraw(true);
   }
}