我是靠谱客的博主 羞涩外套,这篇文章主要介绍openlayers点击直接获取图层数据,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 防抖 _this.mapLayer = _this.olmap.getLayerGroup().getLayers().array_[2]; function debounce(fn, wait) { var timeout; return function() { var context = this; var args = arguments; clearTimeout(timeout); timeout = setTimeout(function() { fn.apply(context, args); }, wait); }; } //调用图层数据 function mapEvt(evt) { var view = _this.olmap.getView(); var viewResolution = view.getResolution(); var source = _this.mapLayer.get("visible") ? _this.mapLayer.getSource() : _this.mapLayer.getSource(); var url = source.getGetFeatureInfoUrl( evt.coordinate, viewResolution, view.getProjection(), { INFO_FORMAT: "text/javascript", FEATURE_COUNT: 1, format_options: "callback: getJson", } ); if (url) { $.ajax({ type: "POST", url: url, async: true, dataType: "jsonp", jsonpCallback: "getJson", success: function(data) { if (data.features.length != 0) { _this.nodelistShow = true; _this.mapEvent = data.features[0].properties; } else { _this.nodelistShow = false; } }, }); } } _this.olmap.on("pointermove", debounce(mapEvt, 100));

最后

以上就是羞涩外套最近收集整理的关于openlayers点击直接获取图层数据的全部内容,更多相关openlayers点击直接获取图层数据内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(82)

评论列表共有 0 条评论

立即
投稿
返回
顶部