[Libreoffice-commits] online.git: loleaflet/src
Henry Castro
hcastro at collabora.com
Mon Jun 15 17:50:35 PDT 2015
loleaflet/src/layer/tile/TileLayer.js | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
New commits:
commit d170ee598e72b99dbfeb654ffd78d2fde4863e0a
Author: Henry Castro <hcastro at collabora.com>
Date: Mon Jun 15 20:44:11 2015 -0400
loleaflet: Add graphics selection.
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 31e3bbd..b22ba9f 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -60,8 +60,12 @@ L.TileLayer = L.GridLayer.extend({
this._bCursorOverlayVisible = false;
// Cursor is visible or hidden (e.g. for graphic selection).
this._bCursorVisible = true;
- // Marker cursor
+ // Rectangle graphic selection
+ this._aGraphicSelection = new L.LatLngBounds( new L.LatLng(0, 0), new L.LatLng(0, 0) );
+ // Cursor marker
this._cursorMarker = null;
+ // Graphic marker
+ this._graphicMarker = null;
},
_initDocument: function () {
@@ -164,6 +168,21 @@ L.TileLayer = L.GridLayer.extend({
this._bCursorOverlayVisible = true;
this._onUpdateCursor();
}
+ else if (textMsg.startsWith('graphicselection:')) {
+ if (textMsg.match('EMPTY')) {
+ this._aGraphicSelection = new L.LatLngBounds( new L.LatLng(0, 0), new L.LatLng(0, 0) );
+ }
+ else {
+ strTwips = textMsg.match(/\d+/g);
+ var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
+ var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
+ var bottomRightTwips = topLeftTwips.add(offset);
+ this._aGraphicSelection = new L.LatLngBounds(
+ this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
+ this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
+ }
+ this._onUpdateGraphicSelection();
+ }
else if (textMsg.startsWith('invalidatetiles:')) {
if (textMsg.match('EMPTY')) {
// invalidate everything
@@ -760,6 +779,17 @@ L.TileLayer = L.GridLayer.extend({
this._bCursorOverlayVisible = false;
}
}
+ },
+
+ _onUpdateGraphicSelection: function () {
+ if (!this._isEmptyRectangle(this._aGraphicSelection)) {
+ this._graphicMarker = L.rectangle(this._aGraphicSelection, {color: 'red', fill: false});
+ this._map.addLayer(this._graphicMarker);
+ }
+ else {
+ if (this._graphicMarker)
+ this._map.removeLayer(this._graphicMarker);
+ }
}
});
More information about the Libreoffice-commits
mailing list