This example shows how to generate permalinks with the current map position and visible layers.
The js is not minified so it is readable. See permalink.js.