Skip to content

Commit

Permalink
fix a bug on remove; demo update
Browse files Browse the repository at this point in the history
  • Loading branch information
cXiaof committed Apr 28, 2019
1 parent be42a2a commit 6b4c5fb
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 30 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 cXiaof
Copyright (c) 2018-2019 cXiaof

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 34 additions & 5 deletions demo/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
//new Map
const map = new maptalks.Map('map', {
center: [121.387, 31.129],
zoom: 14,
baseLayer: new maptalks.TileLayer('base', {
urlTemplate: 'https://webrd{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}',
subdomains: ['01', '02', '03', '04'],
urlTemplate: 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c', 'd'],
attribution:
'&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>',
maxAvailableZoom: 18,
placeholder: true
})
}),
scaleControl: { position: 'bottom-right', metric: true, imperial: true },
zoomControl: { position: { top: 80, right: 20 }, slider: false, zoomLevel: true },
spatialReference: {
projection: 'EPSG:3857',
resolutions: (function() {
const resolutions = []
const d = 2 * 6378137 * Math.PI
for (let i = 0; i < 22; i++) {
resolutions[i] = d / (256 * Math.pow(2, i))
}
return resolutions
})(),
fullExtent: {
top: 6378137 * Math.PI,
bottom: -6378137 * Math.PI,
left: -6378137 * Math.PI,
right: 6378137 * Math.PI
}
}
})

new maptalks.CompassControl({
position: 'top-right'
//new Compass
let compassControl = null
const addCompassControl = () => (compassControl = new maptalks.CompassControl({ position: 'top-right' }).addTo(map))
addCompassControl()

//new Toolbar
const toolbar = new maptalks.control.Toolbar({
position: 'top-left',
items: [{ item: 'add', click: () => addCompassControl() }, { item: 'remove', click: () => compassControl.remove() }]
}).addTo(map)
6 changes: 3 additions & 3 deletions dist/maptalks.control.compass.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* maptalks.control.compass v0.1.0
* maptalks.control.compass v0.1.1
* LICENSE : MIT
* (c) 2016-2019 maptalks.org
*/
Expand Down Expand Up @@ -60,7 +60,7 @@ var CompassControl = function (_maptalks$control$Con) {
this.map.off('moveing', this._rotateCompass, this);
this.map.off('mousemove', this._rotateCompass, this);
this.map.off('viewchange', this._rotateCompass, this);
removeDomNode(this._compass);
this._compass.remove();
delete this._deg;
delete this._compass;
delete this._needle;
Expand Down Expand Up @@ -117,6 +117,6 @@ exports.CompassControl = CompassControl;

Object.defineProperty(exports, '__esModule', { value: true });

typeof console !== 'undefined' && console.log('maptalks.control.compass v0.1.0');
typeof console !== 'undefined' && console.log('maptalks.control.compass v0.1.1');

})));
4 changes: 2 additions & 2 deletions dist/maptalks.control.compass.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/maptalks.control.compass.min.js.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions dist/maptalks.control.compass.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* maptalks.control.compass v0.1.0
* maptalks.control.compass v0.1.1
* LICENSE : MIT
* (c) 2016-2019 maptalks.org
*/
Expand Down Expand Up @@ -54,7 +54,7 @@ var CompassControl = function (_maptalks$control$Con) {
this.map.off('moveing', this._rotateCompass, this);
this.map.off('mousemove', this._rotateCompass, this);
this.map.off('viewchange', this._rotateCompass, this);
removeDomNode(this._compass);
this._compass.remove();
delete this._deg;
delete this._compass;
delete this._needle;
Expand Down Expand Up @@ -109,4 +109,4 @@ CompassControl.mergeOptions(options);

export { CompassControl };

typeof console !== 'undefined' && console.log('maptalks.control.compass v0.1.0');
typeof console !== 'undefined' && console.log('maptalks.control.compass v0.1.1');
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class CompassControl extends maptalks.control.Control {
this.map.off('moveing', this._rotateCompass, this)
this.map.off('mousemove', this._rotateCompass, this)
this.map.off('viewchange', this._rotateCompass, this)
removeDomNode(this._compass)
this._compass.remove()
delete this._deg
delete this._compass
delete this._needle
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maptalks.control.compass",
"version": "0.1.0",
"version": "0.1.1",
"description": "A maptalks Compass Control.",
"license": "MIT",
"author": "cXiaof",
Expand Down Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"babel-eslint": "^10.0.1",
"babel-preset-env": "^1.7.0",
"gulp": "^4.0.0",
"gulp": "^4.0.1",
"maptalks": "^0.44.0",
"maptalks-build-helpers": "^0.5.0"
}
Expand Down
30 changes: 17 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1708,9 +1708,10 @@ glob-stream@^6.1.0:
to-absolute-glob "^2.0.0"
unique-stream "^2.0.2"

glob-watcher@^5.0.0:
glob-watcher@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-5.0.3.tgz#88a8abf1c4d131eb93928994bc4a593c2e5dd626"
resolved "https://registry.npm.taobao.org/glob-watcher/download/glob-watcher-5.0.3.tgz#88a8abf1c4d131eb93928994bc4a593c2e5dd626"
integrity sha1-iKir8cTRMeuTkomUvEpZPC5d1iY=
dependencies:
anymatch "^2.0.0"
async-done "^1.2.0"
Expand Down Expand Up @@ -1770,9 +1771,10 @@ graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

gulp-cli@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/gulp-cli/-/gulp-cli-2.1.0.tgz#2705143ae744c9e10d894ca621ce0a3933aa2e89"
gulp-cli@^2.2.0:
version "2.2.0"
resolved "https://registry.npm.taobao.org/gulp-cli/download/gulp-cli-2.2.0.tgz#5533126eeb7fe415a7e3e84a297d334d5cf70ebc"
integrity sha1-VTMSbut/5BWn4+hKKX0zTVz3Drw=
dependencies:
ansi-colors "^1.0.1"
archy "^1.0.0"
Expand All @@ -1793,13 +1795,14 @@ gulp-cli@^2.0.0:
v8flags "^3.0.1"
yargs "^7.1.0"

gulp@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/gulp/-/gulp-4.0.0.tgz#95766c601dade4a77ed3e7b2b6dc03881b596366"
gulp@^4.0.1:
version "4.0.1"
resolved "https://registry.npm.taobao.org/gulp/download/gulp-4.0.1.tgz#987a38a55a7d3677f6b49e291b06bc05809f33d9"
integrity sha1-mHo4pVp9Nnf2tJ4pGwa8BYCfM9k=
dependencies:
glob-watcher "^5.0.0"
gulp-cli "^2.0.0"
undertaker "^1.0.0"
glob-watcher "^5.0.3"
gulp-cli "^2.2.0"
undertaker "^1.2.1"
vinyl-fs "^3.0.0"

gulplog@^1.0.0:
Expand Down Expand Up @@ -3635,9 +3638,10 @@ undertaker-registry@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/undertaker-registry/-/undertaker-registry-1.0.1.tgz#5e4bda308e4a8a2ae584f9b9a4359a499825cc50"

undertaker@^1.0.0:
undertaker@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/undertaker/-/undertaker-1.2.1.tgz#701662ff8ce358715324dfd492a4f036055dfe4b"
resolved "https://registry.npm.taobao.org/undertaker/download/undertaker-1.2.1.tgz#701662ff8ce358715324dfd492a4f036055dfe4b"
integrity sha1-cBZi/4zjWHFTJN/UkqTwNgVd/ks=
dependencies:
arr-flatten "^1.0.1"
arr-map "^2.0.0"
Expand Down

0 comments on commit 6b4c5fb

Please sign in to comment.