Skip to content

Commit

Permalink
Nativescript Mapbox on iOS retain memory after navigation away #67
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyverbruggen@gmail.com committed Apr 1, 2017
1 parent 696ea17 commit f53ae19
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Awesome native OpenGL-powered maps - by Mapbox

> Note that version 1.5.0+ requires NativeScript 2.3.0.
<img src="https://github.com/EddyVerbruggen/nativescript-mapbox/master/screenshots/ios-demoapp-slice.png" width="375px" height="196px" />

### Use when
Expand Down Expand Up @@ -138,7 +136,7 @@ exports.onMapReady = onMapReady;

Other methods you can invoke like this from an XML-declared map are:
`removeMarkers`, `getCenter`, `setCenter`, `getZoomLevel`, `setZoomLevel`, `getViewport`, `setViewport`, `setTilt`,
`setMapStyle`, `animateCamera`, `addPolygon`, `addPolyline`, `removePolylines` and `setOnMapClickListener`.
`setMapStyle`, `animateCamera`, `addPolygon`, `addPolyline`, `removePolylines`, `setOnMapClickListener` and `destroy`.

Check out the usage details on the functions below.

Expand Down
13 changes: 7 additions & 6 deletions mapbox.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,16 @@ mapbox.unhide = function (arg) {
});
};

mapbox.destroy = function(arg) {
mapbox.destroy = function(arg, nativeMap) {
return new Promise(function (resolve, reject) {
if (mapbox.mapView) {
var viewGroup = mapbox.mapView.getParent();
var theMap = nativeMap || mapbox;
if (theMap.mapView) {
var viewGroup = theMap.mapView.getParent();
if (viewGroup !== null) {
viewGroup.removeView(mapbox.mapView);
viewGroup.removeView(theMap.mapView);
}
mapbox.mapView = null;
mapbox.mapboxMap = null;
theMap.mapView = null;
theMap.mapboxMap = null;
}
});
};
Expand Down
11 changes: 6 additions & 5 deletions mapbox.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,13 @@ mapbox.unhide = function (arg) {
});
};

mapbox.destroy = function(arg) {
mapbox.destroy = function(arg, nativeMap) {
return new Promise(function (resolve, reject) {
if (mapbox.mapView) {
mapbox.mapView.removeFromSuperview();
mapbox.mapView.delegate = null;
mapbox.mapView = null;
var theMap = nativeMap || mapbox.mapView;
if (theMap) {
theMap.removeFromSuperview();
theMap.delegate = null;
theMap = null;
}
});
};
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"name": "nativescript-mapbox",
"version": "2.6.0",
"version": "2.6.1",
"description": "Native Maps, by Mapbox.",
"main": "mapbox",
"typings": "mapbox.d.ts",
"nativescript": {
"platforms": {
"android": "2.3.0",
"ios": "2.3.0"
},
"plugin": {
"nan": true,
"pan": true,
"category": "Interface"
}
},
"repository": {
Expand Down
Binary file removed screenshots/iOS-demo-app.PNG
Binary file not shown.

0 comments on commit f53ae19

Please sign in to comment.