there is already a working script for OL 3.


Is there anyone who can rewrite that in OL 5?

Please as in the example for OL 3 without Ajax, JQuery and NodeJS. Please include with: https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js

closed as off-topic by PolyGeo Dec 30 '18 at 22:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • The links provided were sufficient to demonstrate the problem. Substituting the latest ol js and css urls in the working script produces a run time error when referencing the deprecated ol.animation – Mike Dec 30 '18 at 22:47
  • "deprecated". OK. I have seen in the console a problem with the ".ani" and have hide him. Than was a problem with "getTarget()" and i'm confused. – Suka Dec 31 '18 at 10:35
  • It's better to use getTargetElement() as it always returns a div element, getTarget() can return a div id or element, but when as in the example the element is specified in the map constructor either method will work. – Mike Dec 31 '18 at 10:55

Currently it won't work in OpenLayers 4 or 5 because the the way animations work has changed since OL3.

In ol-popup.js you would need to remove

this.ani = options.ani;
if (this.ani === undefined) {
    this.ani = ol.animation.pan;

and change

if (this.ani && this.ani_opts) {
    this.ani_opts.source = center;

return this.getMap().getView().getCenter();


center = this.getMap().getCoordinateFromPixel(px);
if (this.ani_opts) {
    this.ani_opts.center = center;
} else {

return center;
  • you are realy helpfull! I have a problem, you have a solution. I'm ignore the VOTEWAR! Many thanks @Mike!!! – Suka Dec 31 '18 at 10:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.