- Google .. php-, iframe, css, DIV, , .
"Drag, Dragstart, Dragend", .
, :
getPosition: function (marker) {
var map = this.map ;
var scale = Math.pow(2, map.getZoom());
var nw = new google.maps.LatLng(
map.getBounds().getNorthEast().lat(),
map.getBounds().getSouthWest().lng()
);
var worldCoordinateNW = map.getProjection().fromLatLngToPoint(nw);
var worldCoordinate = map.getProjection().fromLatLngToPoint(marker.getPosition());
var pixelOffset = new google.maps.Point(
Math.floor((worldCoordinate.x - worldCoordinateNW.x) * scale),
Math.floor((worldCoordinate.y - worldCoordinateNW.y) * scale)
);
return pixelOffset;
}
setPosition, , , .
:
google.maps.addEventListener(map, 'drag', function() {setPosition (, );});
setPosition , , , getPosition (marker):
setPosition: function (marker,element) {
var p = this.getPosition(marker),
s = {width:element.offsetWidth,height:element.offsetHeight},
markerOffset = {width:58,height:58};
element.style.left = p.x - (s.width/2) + (markerOffset.width/2) + "px";
element.style.top = p.y - s.height - (markerOffset.height) + 10 + "px";
},