From 72c407e0ed5c3a9ffd2ae518f9f5d4407e1f5d61 Mon Sep 17 00:00:00 2001 From: Andrzej Hunt Date: Tue, 10 Nov 2015 11:44:50 +0100 Subject: [PATCH] loleaflet: support mouse cursor calback --- loleaflet/src/layer/tile/TileLayer.js | 8 ++++++++ loleaflet/src/map/handler/Map.Mouse.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 8f446ea35..eddb2bb87 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -241,6 +241,9 @@ L.TileLayer = L.GridLayer.extend({ msg += 'height=' + this._docHeightTwips; this._onInvalidateTilesMsg(msg); } + else if (textMsg.startsWith('mousepointer:')) { + this._onMousePointerMsg(textMsg); + } else if (textMsg.startsWith('partpagerectangles:')) { this._onPartPageRectanglesMsg(textMsg); } @@ -376,6 +379,11 @@ L.TileLayer = L.GridLayer.extend({ this._onUpdateCellCursor(); }, + _onMousePointerMsg: function (textMsg) { + textMsg = textMsg.substring(14); // "mousepointer: " + this._map._container.style.cursor = textMsg; + }, + _onHyperlinkClickedMsg: function (textMsg) { var link = textMsg.substring(18); window.open(link, '_blank'); diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js index 6477be4f0..82c8c8395 100644 --- a/loleaflet/src/map/handler/Map.Mouse.js +++ b/loleaflet/src/map/handler/Map.Mouse.js @@ -157,6 +157,14 @@ L.Map.Mouse = L.Handler.extend({ this._map.fire('handleautoscroll', { pos: e.containerPoint, map: this._map }); } } + else if (e.type === 'mousemove' && !this._mouseDown) { + clearTimeout(this._mouseOverTimeout); + mousePos = docLayer._latLngToTwips(e.latlng); + this._mouseOverTimeout = setTimeout(L.bind(function() { + docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 0, modifier); + }, this), + 100); + } else if (e.type === 'dblclick' || e.type === 'trplclick' || e.type === 'qdrplclick') { mousePos = docLayer._latLngToTwips(e.latlng); var clicks = {