openlayers5学习笔记-添加Overlay

tmp.addPosition = function (map, item) {
                var ele = document.createElement("div");
                var img = document.createElement("img");
                img.setAttribute('src', '/images/blueIcon.png');

                var a = document.createElement("a");
                a.setAttribute('href', '/pdf?username=' + item.name);
                a.setAttribute('target', '_black');
                a.setAttribute('class', 'positionTitle');
                a.innerHTML = item.name;

                ele.append(img);
                ele.append(a);

                var vienna = new Overlay({
                    position: [item.x,item.y],
                    element: ele
                });

                tmp.map.addOverlay(vienna);
            }

//调用:
tmp.addPosition(map, { x: 102.57374, y:30.51035,name:'测试点'})

 

posted @ 2018-07-25 16:43  接云网络  阅读(2334)  评论(0编辑  收藏  举报