ArcGIS API 4.X 请问自定义<DIV> 如何响应地图事件
view.whenLayerView(featureLayer).then(function (layerView) {
layerView.watch("updating", function (val) {
layerView.queryFeatures().then(function (results) {
results.features.forEach(function (result, index) {
let attributes = result.attributes;
let name = attributes.STNM;
let content = "";
content += `<div class="nav-counter nav-counter-green">`;
content += `<span>${name}</span>`;
content += "</div>";
var tempPopupInstance = new Popup(view);
tempPopupInstance.show(result.geometry, content, {});
});
})
});
});
初始化效果
地图移动之后效果,自定义的<DIV>没有响应地图事件移动,请问该如何处理?
<DIV>show()方法代码如下:
/**
* 显示pop
* @description 弹出框的位置为鼠标点右下角5px
* @param mapPoint {Point} 鼠标经过的点
* @param content {string} 要在弹窗框中显示的内容
* @param style{CSS | style Object} 弹出框的样式,默认样式为"width": "300px", "z-index": "888", "position": "absolute"
*/
show: function(mapPoint, content, style){
this._content = content;
let tempPosition = this._view.toScreen(mapPoint);
this._style= Object.assign(style, {"top": tempPosition.y + 5+"px", "left": tempPosition.x + 5+"px","z-index": "888", "position": "absolute", "word-wrap":"break-word"});
domStyle.set(this._tempPopupDom,this._style);
domConstruct.empty(this._tempPopupDom);
domConstruct.place(this._content, this._tempPopupDom);
}
layerView.watch("updating", function (val) {
layerView.queryFeatures().then(function (results) {
results.features.forEach(function (result, index) {
let attributes = result.attributes;
let name = attributes.STNM;
let content = "";
content += `<div class="nav-counter nav-counter-green">`;
content += `<span>${name}</span>`;
content += "</div>";
var tempPopupInstance = new Popup(view);
tempPopupInstance.show(result.geometry, content, {});
});
})
});
});
初始化效果
地图移动之后效果,自定义的<DIV>没有响应地图事件移动,请问该如何处理?
<DIV>show()方法代码如下:
/**
* 显示pop
* @description 弹出框的位置为鼠标点右下角5px
* @param mapPoint {Point} 鼠标经过的点
* @param content {string} 要在弹窗框中显示的内容
* @param style{CSS | style Object} 弹出框的样式,默认样式为"width": "300px", "z-index": "888", "position": "absolute"
*/
show: function(mapPoint, content, style){
this._content = content;
let tempPosition = this._view.toScreen(mapPoint);
this._style= Object.assign(style, {"top": tempPosition.y + 5+"px", "left": tempPosition.x + 5+"px","z-index": "888", "position": "absolute", "word-wrap":"break-word"});
domStyle.set(this._tempPopupDom,this._style);
domConstruct.empty(this._tempPopupDom);
domConstruct.place(this._content, this._tempPopupDom);
}
2 个回复
swaggyP - 网络粉刷匠
赞同来自: mushroom
风雪中的兔子
赞同来自:
要回复问题请先登录或注册
发起人
相关问题
问题状态