ArcGIS API for js 4.0 BUG (五)GraphicsLayer在elevationInfo:"on-the-ground"时,polygon的PopupTemplate失效
								直接上代码:
注释掉elevationInfo:"on-the-ground",可用。
启用后,polygon的PopupTemplate失效,而point的没有问题。
																				注释掉elevationInfo:"on-the-ground",可用。
启用后,polygon的PopupTemplate失效,而point的没有问题。
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Get started with graphics - 4.0</title>
  <link rel="stylesheet" href="https://js.arcgis.com/4.0/esri ... gt%3B
  <script src="https://js.arcgis.com/4.0/%26q ... gt%3B
  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>
  <script>
    require([
      "esri/Map",
      "esri/layers/GraphicsLayer",
      "esri/PopupTemplate",
      "esri/views/MapView",
      "esri/views/SceneView",
      "esri/Graphic",
      "esri/geometry/Point",
      "esri/geometry/Polygon",
      "esri/symbols/SimpleMarkerSymbol",
      "esri/symbols/SimpleFillSymbol",
      "dojo/domReady!"
    ], function(
      Map, GraphicsLayer, PopupTemplate, MapView, SceneView,
      Graphic, Point, Polygon,
      SimpleMarkerSymbol, SimpleFillSymbol
    ) {
      var map = new Map({
        basemap: "hybrid"
      });
      var view = new SceneView({
        center: [-80, 35],
        container: "viewDiv",
        map: map,
        zoom: 3
      });
      var layer_ship_normal = new GraphicsLayer({
		  	elevationInfo:"on-the-ground",//这句话,可显示PopupTemplate,否则点击无反应
		  });
      map.add(layer_ship_normal);
      // Create a graphic and add the geometry and symbol to it
      var pointGraphic = new Graphic({
        geometry: new Point({
            longitude: -49.97,
            latitude: 41.73
          }),
        symbol: new SimpleMarkerSymbol({
            color: [226, 119, 40],
            outline: { 
              color: [255, 255, 255],
              width: 2
            }
          }),
        popupTemplate: new PopupTemplate({
          title: "This is pointGraphic title.",
          content: "This is pointGraphic content."
        })
      });
      var polygonGraphic = new Graphic({
        geometry: new Polygon({
          rings: [
            [-64.78, 32.3],
            [-66.07, 18.45],
            [-80.21, 25.78],
            [-64.78, 32.3]
          ]
        }),
        symbol: new SimpleFillSymbol({
          color: [227, 139, 79, 0.8],
          outline: {
            color: [255, 255, 255],
            width: 1
          }
        }),
        popupTemplate: new PopupTemplate(({
          title: "This is polygonGraphic title.",
          content: "This is polygonGraphic content."
        }))
      });
      //view.graphics.addMany([pointGraphic, polygonGraphic]);
      layer_ship_normal.addMany([pointGraphic, polygonGraphic]);
    });
  </script>
</head>
<body></body>
</html>
															
		
		
1 个回复
徐鸿至
赞同来自: GIS知乎
要回复问题请先登录或注册