0

I would like to do button like Fly to Bern button in the below link.

Is it possible to do ?

http://openlayers.org/en/v3.2.1/examples/animation.html

var flyToBern = document.getElementById('fly-to-bern');
flyToBern.addEventListener('click', function() {
  var duration = 2000;
  var start = +new Date();
  var pan = ol.animation.pan({
    duration: duration,
    source: /** @type {ol.Coordinate} */ (view.getCenter()),
    start: start
  });
  var bounce = ol.animation.bounce({
    duration: duration,
    resolution: 4 * view.getResolution(),
    start: start
  });
  map.beforeRender(pan, bounce);
  view.setCenter(bern);
}, false);
0

It is possible with Leaflet 1.0, but with a more simple API (you specify only target latlng and duration of the "flyTo" animation).

See Leaflet Fly To Location post for details.

However it does not do anything if you are already on the target position I think.

| improve this answer | |
  • but I cannot just use flyTo.js. It will bring up a error. Unless I use v1.0.0-beta.2 version of leaflet. Do you have any example by using leaflet-0.7.2 version. – Hu Kenneth Nov 12 '15 at 10:47
  • Nope sorry, you need Leaflet 1.0 unfortunately. Or import the code yourself and debug whatever needs to. – ghybs Nov 12 '15 at 10:51

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