earthoutreach / earth-api-utility-library

Automatically exported from code.google.com/p/earth-api-utility-library
0 stars 0 forks source link

DropCallbacks do not work properly when multiple placemarks are made draggable #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Edit the draggable sample code as follows:

gex.dom.clearFeatures();

var pm;
var i;

var draggingStyle = gex.dom.buildStyle({
  icon: {
    stockIcon: 'paddle/red-circle',
    hotSpot: { left: '50%', bottom: 0 }
  }
});

for (i = 0; i < 3; i++)
{ 
  pm = gex.dom.addPointPlacemark([i, 0], {
    name: 'Champion',
    icon: {
      stockIcon: 'paddle/blu-circle',
      hotSpot: { left: '50%', bottom: 0 }
    }
  });

  gex.edit.makeDraggable(pm, {
    dropCallback: function() {
      gex.edit.endDraggable(pm);
    },
    draggingStyle: draggingStyle,
    targetScreenOverlay: {
      icon: 'http://maps.google.com/mapfiles/kml/shapes/cross-hairs.png',
      overlayXY: { left: '50%', top: '50%' },
      screenXY: { left: 0, top: 0 },
      size: { width: 32, height: 32 }
    }
  });
}

What is the expected output? What do you see instead?

Each marker should become undraggable after it is dragged.
What happens is that each callback makes the last placemark
undraggable.

Original issue reported on code.google.com by anneal...@gmail.com on 17 Apr 2010 at 3:14

GoogleCodeExporter commented 8 years ago
Never mind. Newbie error regarding closures and loops...

This does what is needed:

dropCallback: function(value) {return function(){
    gex.edit.endDraggable(value);
  }}(pm)

Original comment by anneal...@gmail.com on 17 Apr 2010 at 7:47

GoogleCodeExporter commented 8 years ago

Original comment by jli...@google.com on 10 Aug 2010 at 4:10