Skip to content

Commit dbb4e2f

Browse files
committed
fixed #60
1 parent 346793d commit dbb4e2f

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/overlay/base/CanvasOverlay.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
setDevicePixelRatio,
66
isString,
77
isArray,
8+
detectmob,
89
isFunction
910
} from '../../common/Util';
1011
import {
@@ -14,6 +15,7 @@ import {
1415
import Toolbar from '../../map/Toolbar';
1516
import ToolTip from '../../map/ToolTip';
1617
let zIndex = 0;
18+
const isMobile = detectmob();
1719

1820
export default class CanvasOverlay extends BaseClass {
1921
constructor(opts) {
@@ -58,7 +60,12 @@ export default class CanvasOverlay extends BaseClass {
5860
map.addEventListener('zoomstart', this._tOnZoomstart);
5961
map.addEventListener('zoomend', this._tOnZoomend);
6062
map.addEventListener('mousemove', this._tMousemove);
61-
map.addEventListener('click', this._tMouseClick);
63+
if (isMobile) {
64+
map.addEventListener('touchstart', this._tMouseClick);
65+
} else {
66+
map.addEventListener('click', this._tMouseClick);
67+
}
68+
6269
if (!map._inmapToolBar) {
6370
map._inmapToolBar = new Toolbar(map.getContainer());
6471
}
@@ -215,7 +222,11 @@ export default class CanvasOverlay extends BaseClass {
215222
this._map.removeEventListener('zoomend', this._tOnZoomend);
216223
this._map.removeEventListener('moving', this._tOnMoving);
217224
this._map.removeEventListener('mousemove', this._tMousemove);
218-
this._map.removeEventListener('click', this._tMouseClick);
225+
if (isMobile) {
226+
this._map.removeEventListener('touchstart', this._tMouseClick);
227+
} else {
228+
this._map.removeEventListener('click', this._tMouseClick);
229+
}
219230
}
220231

221232

src/overlay/base/Parameter.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,18 @@ export default class Parameter extends CanvasOverlay {
279279
*/
280280
_setlegend(legendConfig, list) {
281281
if (!this._map) return;
282-
let option = {};
283-
//legendConfig.list has a higher priority than list
284-
if (!(legendConfig.list && legendConfig.list.length > 0)) {
285-
option = merge(legendConfig, {
286-
list: list
287-
});
282+
let option = {
288283

284+
};
285+
if ((legendConfig.list && legendConfig.list.length > 0)) {
286+
option = {
287+
...legendConfig
288+
};
289+
} else {
290+
option = {
291+
...legendConfig,
292+
list
293+
};
289294
}
290295
this.legend.setOption(option);
291296
}

0 commit comments

Comments
 (0)