Closed jjimenezshaw closed 7 years ago
Interesting feature, thanks for the effort. I've added some comments and will have a look to the actual implementation later. Might be interesting to record some GIFs and add them to the documentation.
@jieter Thanks for your comments. I am open to new ways to explain the feature in the README file. Took me a long time writing it... but still I am not happy with the result. As I know how it works, I understand it. But I am sure it will be difficult for a new user. Feel free to suggest any change ;)
@jieter When you say
Might be interesting to record some GIFs and add them to the documentation
do you mean an animated GIF on the README.md?
Yes, (small) animated GIFs in the readme.
@jieter About different functions, I have just created one that syncs the maps in a global view. The maps will be displayed as a continuous one, doesn't matter where are the divs. If they overlap, they fit perfectly.
function offsetGlobal(center, zoom, refMap, tgtMap) {
var refC = refMap.getContainer();
var tgtC = tgtMap.getContainer();
var pt = refMap.project(center, zoom)
.subtract([refC.offsetLeft, refC.offsetTop])
.subtract(refMap.getSize().divideBy(2))
.add([tgtC.offsetLeft, tgtC.offsetTop])
.add(tgtMap.getSize().divideBy(2));
return refMap.unproject(pt, zoom);
}
Should I include it as part of the code (in L.Util
) or just as an example in the README.md?
@jieter I fixed all your comments (I hope), and added the animated gif (it is a bit small, I don't want to include a 2MB file just for that).
Apart from including or not offsetGlobal
function in the code, I am done.
I'd say add it to the docs, not to the code. I'll merge this, you can open a new PR adding it to the docs.
0.1.0 is the latest of 6 releases
I need to synchronize, not the centers of both maps, but other point. To create a continuous map, or a mosaic, or for any other purpose.
On this pull request the user can pass a function
offsetFn
that defines this transformation. It is very generic to allow flexibility. However, the most common use is really easy with the offsetHelper factory (as explained in the README.md).Now, on each setView or similar function that resets a center, this center is computed with the provided function.
The default value for this option is an identity function, that is, returns the same center.