Closed perliedman closed 10 years ago
Hi, @perliedman
I am curious if this shouldn't also be implemented in the leaflet-proj-refactor
branch? Right now in the project I work on, I use a CustomImageOverlay
layer that I have extended from ImageOverlay
layer with basically all of the modifications you have done in this pull request.
I switched to using soon to be Leaflet 1.0
and noticed that the image overlays started to act strange, so I had to write an extended class that uses this code (and a couple of small modifications) to fix that, but it would be more elegant to just use the library without having to use my extended class.
My modifications for the code in this pull request to work with Leaflet 1.0
is like this:
_animateZoom: function (event) {
var scale = this._map.getZoomScale(event.zoom);
var northWest = L.point(this._projBounds.min.x, this._projBounds.max.y);
var offset = this._projectedToNewLayerPoint(northWest, event.zoom, event.center);
L.DomUtil.setTransform(this._image, offset, scale);
},
_projectedToNewLayerPoint: function (point, zoom, center) {
var viewHalf = this._map.getSize()._divideBy(2);
var newTopLeft = this._map.project(center, zoom)._subtract(viewHalf)._round();
var topLeft = newTopLeft.add(this._map._getMapPanePos());
return this._transform(point, zoom)._subtract(topLeft);
}
Please take a look if this is of any help to you or what should I do to make a pull request that merges this into the leaflet-proj-refactor
branch. Should I just copy the code and modify it from this pull request and create a new pull request against leaflet-proj-refactor
branch?
Adds class
L.Proj.ImageOverlay
, that works exactly asL.ImageOverlay
except that it takes the bounds in projected (map) coordinates instead of LatLngBounds. This makes it possible to add image overlays when working with coordinates systems where latitudes and longitudes do not align with the x and y axis (probably most projections). Inspired from the discussion in #67 and https://github.com/Leaflet/Leaflet/issues/2592.