Hello,
BRIEFLY :
i have trouble to get the pixel coords of my overlay once it dragged
and translate them in LatLng, and then translate LatLng to pixel.
...
I use my own custom overlay based on the documentation example and the
ELabels class from Mike Williams.
I have many troubles with the 'redraw' method when trying to make a
custom overlay draggable ( with JQuery UI draggable plugin).
In fact draggable works fine, but when i finish to drag my overlay,
the redaw method always puts my overlay in another place.
Here is what i 'm doing :
1. init a new overlay :
var ml = new mmOverlay(new GLatLng(47.90050, 1.91352));
map.addOverlay(ml);
network._initOverlay(ml); // this make the overlay draggable - works
fine
2. once the overlay is drag, get the new coords that Jquery give me
for this dragged overlay and translate in LatLng with :
var pixel = ui.position ( new position of dragged element)
point = map.fromContainerPixelToLatLng( new GPoint(pixel.left,
pixel.top) );
3 and then call redraw :
myOverlay.redraw(true, point, pixel);
i change the 'redraw' method :
mmOverlay.prototype.redraw = function(force, point, position) {
if(!force) return;
var $point = point ? point : this.point;
console.log($point, 'point in redraw before fromLatLngToDivPixel');
console.log(position, 'position');
if(!position){
var pixel = this.map_.fromLatLngToDivPixel($point);
this.div_.style.left = (pixel.x + this.pixelOffset.width) +
"px";
this.div_.style.top = (pixel.y +this.pixelOffset.height ) +
"px";
}
else {
this.div_.style.left = position.left + "px";
this.div_.style.top = position.top + "px";
}
this.div_.style.width = this.width_ + "px";
this.div_.style.height = this.height_ + "px";
console.log(this.div_, 'div after redraw');
this.point = $point;
}
Thanks for help.
rccc
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---