From 4b415dba597443f3a1341d7e1c1a3dfd5e175fbb Mon Sep 17 00:00:00 2001 From: fkloft Date: Mon, 23 Dec 2013 23:15:20 +0100 Subject: [PATCH] Only move map when marker reaches edge --- mobile/plugins/user-location.user.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mobile/plugins/user-location.user.js b/mobile/plugins/user-location.user.js index c11ddf94..43b14d93 100644 --- a/mobile/plugins/user-location.user.js +++ b/mobile/plugins/user-location.user.js @@ -115,6 +115,11 @@ window.plugin.userLocation.onLocationChange = function(lat, lng) { window.plugin.userLocation.circle.setLatLng(latlng); if(window.plugin.userLocation.follow) { + // move map if marker moves more than 35% from the center + // 100% - 2*15% = 70% → 35% from center in either direction + if(map.getBounds().pad(-0.15).contains(latlng)) + return; + window.plugin.userLocation.moving = true; window.map.setView(latlng); window.plugin.userLocation.moving = false;