Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
764 views
in Technique[技术] by (71.8m points)

arcgis - ESRI Popup Maximize button missing

Currently working on showing a popup in the map using ESRI ArcGIS API for JavaScript 4.15. But that is missing the Maximize button which was available with ArcGIS API for JavaScript 3.35

enter image description here

Is there any config to be set to show the same.

question from:https://stackoverflow.com/questions/65942297/esri-popup-maximize-button-missing

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As far as I know the new API does not have that capability out of the box. But no worries, you can implement it by adding a custom action to the popup.

See the example I made for you to get an idea.

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  <title>Popup actions | ArcGIS API for JavaScript 4.18</title>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.18/esri/themes/light/main.css" />
  <script src="https://js.arcgis.com/4.18/"></script>

  <script>
    require(["esri/Map", "esri/layers/FeatureLayer", "esri/views/MapView"], function (
      Map,
      FeatureLayer,
      MapView
    ) {
      const map = new Map({
        basemap: "gray-vector"
      });

      const view = new MapView({
        container: "viewDiv",
        map: map,
        center: [-117.08, 34.1],
        zoom: 11
      });

      const toggleFullScreenAction = {
        type: "toggle",
        title: "Full Screen",
        id: "toggle-full-screen",
        className: "esri-icon-maximize"
      };

      view.popup.actions.add(toggleFullScreenAction);


      const template = {
        title: "Trail run",
        content: "{name}"
      };

      featureLayer = new FeatureLayer({
        url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/TrailRuns/FeatureServer/0",
        outFields: ["*"],
        popupTemplate: template
      });
      map.add(featureLayer);

      function toggleFullScreen() {
        if (!document.fullscreenElement) {
          document.getElementsByClassName('esri-popup__main-container')[0].requestFullscreen()
            .catch(err => {
              alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
            });
        } else {
          if (document.exitFullscreen) {
            document.exitFullscreen();
          }
        }
      }

      view.popup.on("trigger-action", function (event) {
        if (event.action.id === "toggle-full-screen") {
          toggleFullScreen();
        }
      });



    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>

</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...