Skip to content

Commit

Permalink
Merge pull request #19 from runette/Stop_Locate
Browse files Browse the repository at this point in the history
Stop locate Fix
  • Loading branch information
runette authored Nov 25, 2022
2 parents 89727ee + d862934 commit 69f42d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
with:
artifacts: "dist/release.tgz"
token: ${{ secrets.GITHUB_TOKEN }}
tag: "2.0.4"
tag: "2.0.5"

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@runette/ngx-leaflet-locate",
"version": "2.0.4",
"version": "2.0.5",
"description": "Angular Wrapper for the Leaflet Location Control",
"keywords": [
"angular",
Expand All @@ -19,7 +19,7 @@
},
"dependencies": {
"@types/leaflet.locatecontrol": "^0.74.0",
"leaflet.locatecontrol": "^0.76.1"
"leaflet.locatecontrol": "^0.78.0"
},
"devDependencies": {
"@angular/common": "^12.0.0",
Expand Down
9 changes: 8 additions & 1 deletion src/lib/ngx-leaflet-locate.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { Component, OnInit, OnDestroy, Input, Output, EventEmitter} from '@angul
import {Map, control, Control, LocationEvent} from 'leaflet';
import '../../../../node_modules/leaflet.locatecontrol/dist/L.Control.Locate.min.js';

interface customMap extends Map {
_unload: any;
}

@Component({
selector: 'leaflet-locate-control',
template: '',
Expand All @@ -20,7 +24,10 @@ export class NgxLeafletLocateComponent implements OnInit, OnDestroy {
};

ngOnDestroy() {
if (this.control && this.map) this.control.stop()
if (this.control && this.map) {
this.control.stop();
this._map?.off("unload", (this.map as customMap)?._unload, this.control);
}
if (this._map && this.control) this._map.removeControl(this.control);
this._map?.off('locationfound')
};
Expand Down

0 comments on commit 69f42d6

Please sign in to comment.