summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--loleaflet/src/geo/LatLngBounds.js29
-rw-r--r--loleaflet/src/layer/tile/TileLayer.js3
-rw-r--r--loleaflet/src/map/handler/Map.TouchGesture.js2
3 files changed, 33 insertions, 1 deletions
diff --git a/loleaflet/src/geo/LatLngBounds.js b/loleaflet/src/geo/LatLngBounds.js
index e6f7396a2..80e059750 100644
--- a/loleaflet/src/geo/LatLngBounds.js
+++ b/loleaflet/src/geo/LatLngBounds.js
@@ -131,6 +131,35 @@ L.LatLngBounds.prototype = {
(sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
},
+ // Similar to contains() but for line selections,
+ // where the whole horizontal area is selected.
+ // This is of course an oversimplification, as
+ // text can be in a column, but at the moment we
+ // don't capture the area of text selections, only
+ // the first and last points.
+ inBand: function (obj) {
+ if (typeof obj[0] === 'number' || obj instanceof L.LatLng) {
+ obj = L.latLng(obj);
+ } else {
+ obj = L.latLngBounds(obj);
+ }
+
+ var sw = this._southWest,
+ ne = this._northEast,
+ sw2, ne2;
+
+ if (obj instanceof L.LatLngBounds) {
+ sw2 = obj.getSouthWest();
+ ne2 = obj.getNorthEast();
+ } else {
+ sw2 = ne2 = obj;
+ }
+
+ // Assume the longitudes are 100% the document width,
+ // so always matches.
+ return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat);
+ },
+
intersects: function (bounds) { // (LatLngBounds)
bounds = L.latLngBounds(bounds);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 26afa6c71..0da191937 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1705,6 +1705,9 @@ L.TileLayer = L.GridLayer.extend({
var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
var bottomRightTwips = topLeftTwips.add(offset);
var oldSelection = this._textSelectionStart;
+ //FIXME: The selection is really not two points, as they can be
+ //FIXME: on top of each other, but on separate lines. We should
+ //FIXME: capture the whole area in _onTextSelectionMsg.
this._textSelectionStart = new L.LatLngBounds(
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js
index 01544d5de..d682cb4c5 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -268,7 +268,7 @@ L.Map.TouchGesture = L.Handler.extend({
if (docLayer._textSelectionStart && docLayer._textSelectionEnd)
textSelection = new L.LatLngBounds(docLayer._textSelectionStart.getSouthWest(), docLayer._textSelectionEnd.getNorthEast());
- if ((textSelection && textSelection.contains(latlng))
+ if ((textSelection && textSelection.inBand(latlng))
|| (graphicSelection && graphicSelection.contains(latlng))
|| (cellCursor && cellCursor.contains(latlng))) {
// long touched an already selected object