kkpowar / gmaps-utility-library-dev

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

Make LabeledMarker support dragging #55

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

In the current version of LabeledMarker, the dragging is not supported yet.
So i think this could be a cool new feature (in fact i need it :->)
I already made a patch for that.
The idea is to use the latlng of his Marker parent instead of using an
other internal variable.

Tell me your feeling about this patch.

cheers

Original issue reported on code.google.com by gregory....@gmail.com on 20 Aug 2008 at 1:07

Attachments:

GoogleCodeExporter commented 8 years ago
When I tried doing draggability in LabeledMarker, the problem was that the label
moved down on the marker while it was being dragged, and that didn't look great.
Yours doesn't seem to address that issue. Do you have a demo?

Original comment by pamela.fox on 27 Aug 2008 at 5:56

GoogleCodeExporter commented 8 years ago
Indeed, i forget to address that issue (sorry). i have the same problem and i 
don't
already have a good patch to solve it. Currently i play with the label offset. 
For
that, i added the following function in the labeledmarker.js file: 

LabeledMarker.prototype.setLabelOffset = function(labelOffset) {
    this.labelOffset_ = labelOffset;
    this.redrawLabel_();
}

and in my own code, the following events:

GEvent.addListener(labeledMarker, "dragstart", 
GEvent.callbackArgs(labeledMarker,
function(label) {
   this.setLabelOffset(new GSize(label.length > 8 ? -6 : -3, -35));
}, this));
GEvent.addListener(marker, "dragend", GEvent.callbackArgs(labeledMarker,
function(label) {
   this.setLabelOffset(new GSize(label.length > 8 ? -6 : -3, -22));
}, this));

But obviously this not a good solution, i need to find a better one putting all 
the
code in the labelmarker.js file.

Original comment by gregory....@gmail.com on 27 Aug 2008 at 8:03

GoogleCodeExporter commented 8 years ago
I have changed redrawLabel_ method (only two lines):  
  var p = this.map_.fromLatLngToDivPixel(this.getLatLng());
  var z = GOverlay.getZIndex(this.getLatLng().lat());

(use parent getLatLng() method instead of internal latlng_ property)

and text label now dragged with icon.

Original comment by theVi...@gmail.com on 30 Aug 2008 at 7:13

GoogleCodeExporter commented 8 years ago
gregory- I'm not sure there's actually a good solution besides actually 
exposing the
current height offset of the marker through the API (which I thought about, but
couldn't decide best way to expose), or just disabling the label during 
dragging.

theVisor- The label drags, but it drags below the icon.

Original comment by pamela.fox on 30 Aug 2008 at 2:05