From 48478c6868521b40f159c2b3ee5073d328e91e1e Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Sat, 6 Dec 2014 15:21:14 +0100 Subject: [PATCH] Listen 'mousemove' and 'click' rather than 'pointermove' in the TileUTFGrid example --- examples/tileutfgrid.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/tileutfgrid.js b/examples/tileutfgrid.js index 66e864714e..d95a2a92db 100644 --- a/examples/tileutfgrid.js +++ b/examples/tileutfgrid.js @@ -41,9 +41,9 @@ var infoOverlay = new ol.Overlay({ }); map.addOverlay(infoOverlay); -map.on('pointermove', function(evt) { +var displayCountryInfo = function(coordinate) { var viewResolution = /** @type {number} */ (view.getResolution()); - gridSource.forDataAtCoordinateAndResolution(evt.coordinate, viewResolution, + gridSource.forDataAtCoordinateAndResolution(coordinate, viewResolution, function(data) { // If you want to use the template from the TileJSON, // load the mustache.js library separately and call @@ -55,6 +55,15 @@ map.on('pointermove', function(evt) { nameElement.innerHTML = data['admin']; /* jshint +W069 */ } - infoOverlay.setPosition(data ? evt.coordinate : undefined); + infoOverlay.setPosition(data ? coordinate : undefined); }); +}; + +$(map.getViewport()).on('mousemove', function(evt) { + var coordinate = map.getEventCoordinate(evt.originalEvent); + displayCountryInfo(coordinate); +}); + +map.on('click', function(evt) { + displayCountryInfo(evt.coordinate); });