-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an example showing how to create a permalink #3560
Conversation
LGTM thanks for adding this, please merge if Travis gives the okay |
the only thing I wondered is if we should keep the anchor structure the same as in OpenLayers 2 to make it easier for people that are coming from OpenLayers 2?
|
Nice! View rotation could also be added to the permalink. |
And then of course, the History API could be used to navigate through the viewed extents... but maybe that's for a separate improvement pull request to this new example. |
We could also demonstrate how to work with existing libraries :). var hashed = require('hashed');
// custom serializers/deserializers can also be supplied
// but we'll start with just the defaults
var defaults = {x: 0, y: 0, z: 1};
function onChange(hash) {
var view = map.getView();
view.setCenter([hash.x, hash.y]);
view.setZoom(hash.z);
}
var update = hashed.register(defaults, onChange);
map.on('moveend', function() {
var view = map.getView();
var center = view.getCenter();
update({x: center[0], y: center[1], z: view.getZoom()});
});
// now the back/forward buttons navigate through map history! |
<div class="span12"> | ||
<div id="map" class="map"></div> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this (and permalink.js
) to examples
instead of examples_src
. Rebasing on master should do the trick.
f993b62
to
c9c7bff
Compare
I updated the example, now the History API is used and also the rotation is taken into account.
@bartvde I am now using the OSM schema: #map=5/41.146/25.488.
@tschaub Nice library! Could you also use it together with the History API? |
c9c7bff
to
75910ab
Compare
Sorry, I didn't want to close this... A very nice example! Which versions of IE do support the History API? Will this silently fail in browsers that don't support it? If so, this is good to be merged. Thanks, @tsauerwein |
A simple comment in the docs of the example would be sufficient. Please merge with or without adding such a comment. |
75910ab
to
616b417
Compare
LGTM, the values could be simplified a bit; centimeter level should be enough |
616b417
to
b8ec2e2
Compare
@fredj Good point! I will merge when Travis passes, thanks for all the feedback. |
Add an example showing how to create a permalink
A small example in which the URL is updated with the current zoom-level and center every time the map is moved. When reloading center and zoom-level are restored from the URL.