【问题标题】:Scrolling down a page with a ArcGIS map使用 ArcGIS 地图向下滚动页面
【发布时间】:2016-09-14 20:44:05
【问题描述】:

我的地图使用的是 ArcGIS API 4.0 版。

每当加载地图时,用户必须向下滚动才能查看地图。 这是我面临的第一个问题。

我的地图位于页面中间的某个位置,因此用户必须向下滚动才能查看它。

然后,如果在地图上单击某个点或拖动某个区域进行放大,则地图显示为选择的指针不是鼠标指向的确切点。它指向鼠标指针上方的位置。

这是一个示例代码。

    <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Add the Compass widget to a basic 2D map - 4.0</title>

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

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

  <script>
    require([
        "esri/Map",
        "esri/views/MapView",
        "esri/widgets/Compass",
        "dojo/domReady!"
      ],
      function(
        Map,
        MapView,
        Compass
      ) {

        var map = new Map({
          basemap: "national-geographic"
        });

        var view = new MapView({
          container: "viewDiv",
          scale: 500000,
          center: [26.26, 39.17],
          map: map
        });

        /********************************
         * Create a compass widget object.
         *********************************/

        var compassWidget = new Compass({
          view: view
        });

        // Add the Compass widget to the top left corner of the view
        view.ui.add(compassWidget, "top-left");
      });
  </script>
</head>
<body>
<!-- add div for test-->
<div style="height:500px;"></div>
  <div id="viewDiv"></div>
</body>
</html>

注意:- arcgsi js api 示例也存在同样的问题... https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=get-started-mapview

如果您运行此代码,您将看到如果您向下滚动并拖动一个区域(按住 shift 并拖动鼠标),它将在您的选择上方拖动一个区域。

【问题讨论】:

    标签: javascript arcgis esri arcgis-js-api


    【解决方案1】:

    嗯,我注意到每当用户滚动时都会发生这种情况。 所以我建议要么删除滚动条,要么减小顶部标题容器的大小。

    更多细节请参考下面的运行代码:-

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
      <title>Add the Compass widget to a basic 2D map - 4.0</title>
    
      <style>
            html,
        body,
        #viewDiv {
          padding: 0;
          margin: 0;
          height: 100%;
          width: 100%;
          overflow: hidden;
        }
        
      </style>
    
      <link rel="stylesheet" href="https://js.arcgis.com/4.0/esri/css/main.css">
      <script src="https://js.arcgis.com/4.0/"></script>
    
      <script>
        require([
            "esri/Map",
            "esri/views/MapView",
            "esri/widgets/Compass",
            "dojo/domReady!"
          ],
          function(
            Map,
            MapView,
            Compass
          ) {
    
            var map = new Map({
              basemap: "national-geographic"
            });
    
            var view = new MapView({
              container: "viewDiv",
              scale: 500000,
              center: [26.26, 39.17],
              map: map
            });
    
            /********************************
             * Create a compass widget object.
             *********************************/
    
            var compassWidget = new Compass({
              view: view
            });
    
            // Add the Compass widget to the top left corner of the view
            view.ui.add(compassWidget, "top-left");
          });
      </script>
    </head>
    <body>
    <!-- add div for test-->
    <div style="height:100px;"></div>
      <div id="viewDiv"></div>
    </body>
    </html>

    希望这会对您有所帮助 :)

    【讨论】:

    • 高度=500px; div 应该在地图 div 的上方。该 div 将包含一些标题信息。地图 div 不能在该 div 内。
    • 一点也不。现在我什至无法在较小的屏幕上看到地图。 :D
    • 滚动条存在一些问题......同样的问题也发生在 arcgis js api 上......developers.arcgis.com/javascript/latest/sample-code/sandbox/… 在正文中添加此内容
      并检查...
    • 是的。好吧,我厌倦了所有可能的方式,但无法完成这项工作。这只发生在 4.0 中。
    【解决方案2】:

    我在其中一个 ArcGIS 论坛上发布了此内容,并了解到这是 4.0 的一个错误,将在 4.1 中修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-08
      • 2014-10-02
      • 1970-01-01
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      • 2015-01-19
      相关资源
      最近更新 更多