ember-leaflet icon indicating copy to clipboard operation
ember-leaflet copied to clipboard

Get MarkerLayer location on "dragend" event

Open zzarcon opened this issue 10 years ago • 0 comments

Hi guys, I have a MapView with a MarkerCollectionLayer as childLayers, and that MarkerCollectionLayer has a MarkerLayer that extends the DraggableMixin, so I'm trying to get the location of the MarkerLayer when it's dragged...

var markerLayer = EmberLeaflet.MarkerLayer.extend(EmberLeaflet.DraggableMixin, EmberLeaflet.PopupMixin, {
  dragend: function() {
     //The value of this.get('location') is always the same
  }
});

var marker = EmberLeaflet.MarkerCollectionLayer.extend({
  itemLayerClass: markerLayer,
  events: ['click'],

  content: function() {
    var lat = this.get('controller.geolocator.latitude');
    var lon = this.get('controller.geolocator.longitude');

    return [{location: L.latLng(lat, lon)}];
  }.property('controller.geolocator.latitude', 'controller.geolocator.longitude')
});

export default EmberLeaflet.MapView.extend({
  zoom: 15,
  options: {maxZoom: 19, minZoom: 0},
  events: ['click'],
  childLayers: [EmberLeaflet.DefaultTileLayer, marker],

  center: function() {
    return L.latLng(
      this.get('controller.geolocator.latitude'),
      this.get('controller.geolocator.longitude')
    );
  }.property('controller.geolocator.latitude', 'controller.geolocator.longitude')
});

The problem is that in the dragend handler I'm getting always the same value :(. What I'm doing wrong? Thanks!!!

zzarcon avatar Dec 12 '14 21:12 zzarcon