From 427614ccca8665a762f9e9e7185f25e517c6946a Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sat, 22 Mar 2014 03:34:46 +0000 Subject: [PATCH] mobile - show-user-location 1. if canvas-based layers are in use, don't draw the hack range marker (as any leaflet path-based drawing is slow, and they don't support SVG styles) 2. only add/remove the circle marker layer when needed - as the leaflet library doesn't document what will happen if a removed layer is removed again, or an added layer is added again --- mobile/plugins/user-location.user.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mobile/plugins/user-location.user.js b/mobile/plugins/user-location.user.js index 5b9bdb3c..93895a6a 100644 --- a/mobile/plugins/user-location.user.js +++ b/mobile/plugins/user-location.user.js @@ -66,10 +66,13 @@ window.plugin.userLocation.setup = function() { }; window.plugin.userLocation.onZoomEnd = function() { - if(window.map.getZoom() < 16) - window.plugin.userLocation.locationLayer.removeLayer(window.plugin.userLocation.circle); - else - window.plugin.userLocation.locationLayer.addLayer(window.plugin.userLocation.circle); + if(window.map.getZoom() < 16 || L.Path.CANVAS) { + if (window.plugin.userLocation.locationLayer.hasLayer(window.plugin.userLocation.circle)) + window.plugin.userLocation.locationLayer.removeLayer(window.plugin.userLocation.circle); + } else { + if (!window.plugin.userLocation.locationLayer.hasLayer(window.plugin.userLocation.circle)) + window.plugin.userLocation.locationLayer.addLayer(window.plugin.userLocation.circle); + } }; window.plugin.userLocation.locate = function(lat, lng, accuracy) {