二维气泡弹窗

 

   // 查找地图所有的layers,找到之前的标记,隐藏掉
     var layers = map.layers;
        for (var i = 0; i < layers.length; i++) {
            if (layers[i].name == "markerLayer") {
                layers[i].setOpacity(0);
            }
        }
        // 关闭二维气泡弹窗
        closeInfoWin();
        // 添加地图marker
        markerlayer = new SuperMap.Layer.Markers("markerLayer");
        var size = new SuperMap.Size(44, 33);
        var offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
        var icon = new SuperMap.Icon('./images/marker.png', size, offset);
        marker = new SuperMap.Marker(new SuperMap.LonLat(point[0], point[1]), icon);
        markerlayer.addMarker(marker);
        map.addLayer(markerlayer);
        // 设置中心点,缩放比例
        map.setCenter(new SuperMap.LonLat(point[0], point[1]), 8);

        var lonlat = marker.getLonLat();
        var contentHTML = "<div style='font-size:.8em; opacity: 0.8; overflow-y:hidden;'>";
        contentHTML += "<p>高(毫米) :" + rowData.SSPIPEHEIGHT + "</p></div>";
     var popup = new SuperMap.Popup.FramedCloud("popwin", new SuperMap.LonLat(lonlat.lon, lonlat.lat), null, contentHTML, null, true);
        infowin = popup;
        map.addPopup(popup);     
// 关闭二维弹出气泡
  function closeInfoWin() {
      if (infowin) {
          try {
              infowin.hide();
              infowin.destroy();
          }
          catch (e) {
          }
      }
  }

 

posted @ 2020-09-24 14:13  万里哥  阅读(161)  评论(0编辑  收藏  举报