注明:这篇文章来自于黑客志,对HTML5的本次存储方式进行了非常全面的介绍和分析,对于学习HTML5的开发者来说,不容错过哦。历史在HTML5本地存储之前,如果我们想在客户端保存持久化数据,有这么
顺晟科技
2022-09-16 07:34:16
153
map_click() {
this.map.on("click", (e) => {
var pixel = this.map.getEventPixel(e.originalEvent);
console.log(pixel)
var coordinate = e.coordinate;
var feature = this.map.forEachFeatureAtPixel(pixel, (feature) => {return feature});
console.log(feature)
if(feature){
console.log("获取到点击的要素" + "jingdu:" + coordinate[0]); //其中lei是定义的属性
// this.datas = feature.values_
this.$refs.popup_content.innerHTML = '<code>' + feature.values_.id + '</code>'; //弹窗内容
this.overlay.setPosition(coordinate);
}else {
this.overlay.setPosition(undefined); // 如果没有点击坐标点,就隐藏弹窗
}
});
},
这个是点击矢量图层出现弹框的代码下面一个一个绿色的小圆圈就是一个个的矢量图层首次进入这个页面的时候,从本地获取到数据渲染出来然后点击绿色的小圆点,获取不到上述代码里面的feature这个时候把上面的console.log() 这个给注释掉保存代码以后 不要刷新页面从新渲染一次绿色的小圆点这个时候点击就会出现
是那一步出错了呢?
18
2022-10
25
2022-09
25
2022-09
16
2022-09
16
2022-09
16
2022-09