
var map = new maptalks.Map('map', {
  center: [121.48542888885189, 31.228541533313702],
  zoom: 14,
  baseLayer: new maptalks.TileLayer('base', {
    urlTemplate: '$(urlTemplate)',
    subdomains: $(subdomains)
  })
});

var layer = new maptalks.VectorLayer('vector').addTo(map);

var marker = new maptalks.Marker([121.48542, 31.22854]).addTo(layer);

function fly(type) {
  var offset = getFlyOffset(type);
  marker.animate({
    translate: [offset['x'], offset['y']]
  }, {
    speed: 2000
  });
}

function getFlyOffset(type) {
  var winHeight = document.body.clientHeight;
  var offsetPoint = new maptalks.Point(0, -winHeight);
  var sourcePoint = map.coordinateToViewPoint(coordinate);
  var point = sourcePoint.add(offsetPoint);
  var startOrStopPoint = map.viewPointToCoordinate(point);
  var offset = startOrStopPoint.substract(coordinate);
  if (type === 'flyIn') {
    marker.setCoordinates(startOrStopPoint);
    offset = coordinate.substract(startOrStopPoint);
  }
  return offset;
}

var toolbar = new maptalks.control.Toolbar({
  items: [
    {
      item: 'FLY IN',
      click: function () {
        fly('flyIn');
      }
    },
    {
      item: 'FLY OUT',
      click: function () {
        fly('flyOut');
      }
    }
  ]
}).addTo(map);

@@ -278,19 +278,22 @@
 p);%0A
-%0A
 var 
-marker
+coordinate
  = n
@@ -308,16 +308,19 @@
 lks.
-Marker(%5B
+Coordinate(
 121.
@@ -334,17 +334,62 @@
 31.22854
-%5D
+);%0Avar marker = new maptalks.Marker(coordinate
 ).addTo(

fix in-out