Raruto/leaflet-rotate

Compatibility with Leaflet 1.9.2

Closed this issue · 4 comments

I know that it states compatible with Leaflet 1.7
However, I tested this plugin with Leaflet 1.9.2 and everything works except from popups that stay anchored to the old position without getting the rotation transformation applied.
Could you please look into this?

Hi @alessandro-dallatorre,

every file included in this library does nothing but slightly alter (overriding) the prototypes of some functions defined in the core, eg:

const popupProto = L.extend({}, L.Popup.prototype);
L.Popup.include({

in particular, only two functions are modified within that file:

/**
* L.Popup
*/
const popupProto = L.extend({}, L.Popup.prototype);
L.Popup.include({
_animateZoom: function(e) {
if (!this._map._rotate) {
popupProto._animateZoom.call(this, e);
}
var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),
anchor = this._getAnchor();
pos = this._map.rotatedPointToMapPanePoint(pos);
L.DomUtil.setPosition(this._container, pos.add(anchor));
},
_adjustPan: function() {
if (!this.options.autoPan || (this._map._panAnim && this._map._panAnim._inProgress)) { return; }
var map = this._map,
marginBottom = parseInt(L.DomUtil.getStyle(this._container, 'marginBottom'), 10) || 0,
containerHeight = this._container.offsetHeight + marginBottom,
containerWidth = this._containerWidth,
layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
layerPos._add(L.DomUtil.getPosition(this._container));
// var containerPos = map.layerPointToContainerPoint(layerPos);
// TODO: use popupProto._adjustPan
var containerPos = layerPos._add(this._map._getMapPanePos()),
padding = L.point(this.options.autoPanPadding),
paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),
paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding),
size = map.getSize(),
dx = 0,
dy = 0;
if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right
dx = containerPos.x + containerWidth - size.x + paddingBR.x;
}
if (containerPos.x - dx - paddingTL.x < 0) { // left
dx = containerPos.x - paddingTL.x;
}
if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom
dy = containerPos.y + containerHeight - size.y + paddingBR.y;
}
if (containerPos.y - dy - paddingTL.y < 0) { // top
dy = containerPos.y - paddingTL.y;
}
// @namespace Map
// @section Popup events
// @event autopanstart: Event
// Fired when the map starts autopanning when opening a popup.
if (dx || dy) {
map
.fire('autopanstart')
.panBy([dx, dy]);
}
},
});

as i am not a core developer either, please try to check yourself too if anything has changed in the meantime inside that file:

At the moment, you may be waiting a very long time before I get in on it...

Thanks for any cooperation,
Raruto

@alessandro-dallatorre I did a quick test with version leaflet@v1.9.2 and it seems ok to me.

If not, please also provide a public example that reproduces the issue, otherwise I consider this issue resolved

Have a nice day,
Raruto

Yes, please wait and I'll post some code and screenshots.

popups that stay anchored to the old position without getting the rotation transformation applied.

@alessandro-dallatorre it is not clear what exactly you are referring to, but this should be the default behavior (markers, popups and tooltips by default are not added to rotatePane, see also: Map Panes documentation and #2 (comment))

this.createPane('markerPane', this._norotatePane);
this.createPane('tooltipPane', this._norotatePane);
this.createPane('popupPane', this._norotatePane);

please wait and I'll post some code and screenshots.

It's been a while, if you think there is still a problem please open a new specific issue and provide more detailed information about it

I do my best to at least keep the plugin aligned with the main leaflet structure, but I don't have the resources to test or support only myself all the available features..