Skip to content

Commit

Permalink
fixed #60
Browse files Browse the repository at this point in the history
  • Loading branch information
fengluhome committed Jan 25, 2019
1 parent 346793d commit dbb4e2f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
15 changes: 13 additions & 2 deletions src/overlay/base/CanvasOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
setDevicePixelRatio,
isString,
isArray,
detectmob,
isFunction
} from '../../common/Util';
import {
Expand All @@ -14,6 +15,7 @@ import {
import Toolbar from '../../map/Toolbar';
import ToolTip from '../../map/ToolTip';
let zIndex = 0;
const isMobile = detectmob();

export default class CanvasOverlay extends BaseClass {
constructor(opts) {
Expand Down Expand Up @@ -58,7 +60,12 @@ export default class CanvasOverlay extends BaseClass {
map.addEventListener('zoomstart', this._tOnZoomstart);
map.addEventListener('zoomend', this._tOnZoomend);
map.addEventListener('mousemove', this._tMousemove);
map.addEventListener('click', this._tMouseClick);
if (isMobile) {
map.addEventListener('touchstart', this._tMouseClick);
} else {
map.addEventListener('click', this._tMouseClick);
}

if (!map._inmapToolBar) {
map._inmapToolBar = new Toolbar(map.getContainer());
}
Expand Down Expand Up @@ -215,7 +222,11 @@ export default class CanvasOverlay extends BaseClass {
this._map.removeEventListener('zoomend', this._tOnZoomend);
this._map.removeEventListener('moving', this._tOnMoving);
this._map.removeEventListener('mousemove', this._tMousemove);
this._map.removeEventListener('click', this._tMouseClick);
if (isMobile) {
this._map.removeEventListener('touchstart', this._tMouseClick);
} else {
this._map.removeEventListener('click', this._tMouseClick);
}
}


Expand Down
17 changes: 11 additions & 6 deletions src/overlay/base/Parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,18 @@ export default class Parameter extends CanvasOverlay {
*/
_setlegend(legendConfig, list) {
if (!this._map) return;
let option = {};
//legendConfig.list has a higher priority than list
if (!(legendConfig.list && legendConfig.list.length > 0)) {
option = merge(legendConfig, {
list: list
});
let option = {

};
if ((legendConfig.list && legendConfig.list.length > 0)) {
option = {
...legendConfig
};
} else {
option = {
...legendConfig,
list
};
}
this.legend.setOption(option);
}
Expand Down

0 comments on commit dbb4e2f

Please sign in to comment.