Best way to store Leaflet map extent between page visits?

142 views
Skip to first unread message

ab16.a1

unread,
Apr 18, 2014, 9:30:48 PM4/18/14
to leafl...@googlegroups.com
When I return to my website I want to get my last map extent back.

What is the right way to do that please?

I could use Javascript to write a cookie? What event should drive the writing of a cookie?

Any assistance appreciated.




Arnie Shore

unread,
Apr 18, 2014, 9:56:08 PM4/18/14
to leafl...@googlegroups.com
You might look into this  => https://github.com/mlevans/leaflet-hash for some of what you will need, I believe

AS


--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ab16.a1

unread,
Apr 18, 2014, 11:22:55 PM4/18/14
to leafl...@googlegroups.com
Thanks Arnie the hashes could be useful later in my project.

Yeah I need the between session saving.

I can get the extend out of getBounds()

Pat Keller

unread,
Apr 21, 2014, 12:09:25 AM4/21/14
to leafl...@googlegroups.com
I think I would call getCenter() and getZoom() and save those 2 values somewhere when the window/tab is closing. Looks like the onunload event is fired when a window is closed or page is unloaded http://www.w3schools.com/jsref/event_onunload.asp

ab16.a1

unread,
Apr 25, 2014, 6:44:55 AM4/25/14
to leafl...@googlegroups.com
OK guys I've determined that wanting to keep extent between page views is a design flaw in my application.
I realized that each page has completely different functionality (e.g 1 page I draw polygons another I review points) and starting a page with fitBounds or setView is enough.
This is probably why there is nearly no chatter on this topic.
Thank you for you patience.
:D
Reply all
Reply to author
Forward
0 new messages