From c1cd2f495b4b9e3c3857625181e8d351ba3295fb Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Wed, 18 Jan 2017 22:59:35 +0100 Subject: [PATCH] Remove markers from internal cache #72 --- mapbox.ios.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mapbox.ios.js b/mapbox.ios.js index 7b5e6fa..691b61d 100755 --- a/mapbox.ios.js +++ b/mapbox.ios.js @@ -218,12 +218,16 @@ mapbox.removeMarkers = function (ids, nativeMap) { markersToRemove.push(marker.ios); } } - + // remove markers from cache - mapbox._markers = mapbox._markers.filter(function (marker) { - return ids.indexOf(marker.id) < 0; - }) - + if (ids) { + mapbox._markers = mapbox._markers.filter(function (marker) { + return ids.indexOf(marker.id) < 0; + }); + } else { + mapbox._markers = []; + } + if (markersToRemove.length > 0) { theMap.removeAnnotations(markersToRemove); }