15 lines
490 B
JavaScript
15 lines
490 B
JavaScript
/* Additional Leaflet functions */
|
|
|
|
L.Map.include({
|
|
setOffsetView: function (iOffsetRatioX, oCenter, iZoomLevel) {
|
|
var oCenter = (typeof oCenter == 'object')?$.extend({}, oCenter):this.getCenter();
|
|
iZoomLevel = iZoomLevel || this.getZoom();
|
|
|
|
var oBounds = this.getBounds();
|
|
var iOffsetX = (oBounds.getEast() - oBounds.getWest()) * iOffsetRatioX / ( 2 * Math.pow(2, iZoomLevel - this.getZoom()));
|
|
oCenter.lng = oCenter.lng - iOffsetX;
|
|
|
|
this.setView(oCenter, iZoomLevel);
|
|
}
|
|
});
|