From db42f10cebf8c290dce9b862231b7608b2bfa370 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 1 Feb 2015 13:06:35 +0000 Subject: [PATCH] plugin regions: fix region name sometimes being positioned outside of the actual cell when a rotated (diamond-like) cell is just off the corners of the screen --- plugins/regions.user.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/regions.user.js b/plugins/regions.user.js index 0dd60538..1d7b658b 100644 --- a/plugins/regions.user.js +++ b/plugins/regions.user.js @@ -2,7 +2,7 @@ // @id iitc-plugin-regions@jonatkins // @name IITC plugin: Show the local score regions // @category Layer -// @version 0.1.0.@@DATETIMEVERSION@@ +// @version 0.1.1.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -205,10 +205,11 @@ window.plugin.regions.drawCell = function(cell) { var newpos = L.latLng(newlat,newlng); - // ensure the new centre point is within the corners - var cornerbounds = L.latLngBounds([corners[0],corners[1]]).extend(corners[2]).extend(corners[3]); - - if (cornerbounds.contains(newpos)) center=newpos; + // ensure the new position is still within the same cell + var newposcell = S2.S2Cell.FromLatLng ( newpos, 6 ); + if ( newposcell.toString() == cell.toString() ) { + center=newpos; + } // else we leave the name where it was - offscreen } }