plugin: player tracker. something odd was happening in the case of $.each and 'this' in the loop function - so changed to use parameters to functions

This commit is contained in:
Jon Atkins 2013-12-01 03:31:53 +00:00
parent b17b4c6a78
commit 25fe86b43c

View File

@ -250,9 +250,9 @@ window.plugin.playerTracker.getLatLngFromEvent = function(ev) {
//TODO? add weight to certain events, or otherwise prefer them, to give better locations? //TODO? add weight to certain events, or otherwise prefer them, to give better locations?
var lats = 0; var lats = 0;
var lngs = 0; var lngs = 0;
$.each(ev.latlngs, function() { $.each(ev.latlngs, function(i, latlng) {
lats += this[0]; lats += latlng[0];
lngs += this[1]; lngs += latlng[1];
}); });
return L.latLng(lats / ev.latlngs.length, lngs / ev.latlngs.length); return L.latLng(lats / ev.latlngs.length, lngs / ev.latlngs.length);
@ -344,15 +344,15 @@ window.plugin.playerTracker.drawData = function() {
var eventPortal = [] var eventPortal = []
var closestPortal; var closestPortal;
var mostPortals = 0; var mostPortals = 0;
$.each(last.guids, function() { $.each(last.guids, function(i, guid) {
if(eventPortal[this]) { if(eventPortal[guid]) {
eventPortal[this]++; eventPortal[guid]++;
} else { } else {
eventPortal[this] = 1; eventPortal[guid] = 1;
} }
if(eventPortal[this] > mostPortals) { if(eventPortal[guid] > mostPortals) {
mostPortals = eventPortal[this]; mostPortals = eventPortal[guid];
closestPortal = this; closestPortal = guid;
} }
}); });