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, {});
                         });
                })        

       });
});

无标题.png

初始化效果
无标题2.png

地图移动之后效果,自定义的<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);
}
 
已邀请:

swaggyP - 网络粉刷匠

赞同来自: mushroom

监听view的exten变化,然后去刷新div的位置吧view.watch("extent",function(){"do something"})

风雪中的兔子

赞同来自:

请问楼主,你的问题解决了吗?最终怎么处理的

要回复问题请先登录注册