用js调用portal中用户所发布的webmap并在该地图上添加点如何用代码实现,我的总是报错。。。。

已邀请:

atlas1563

赞同来自: Alisa

"dojo/domReady!"放最后

lhx - 上路lu

赞同来自: Alisa

看到你的解决了我的问题good

Alisa

赞同来自:

<script>
    require([
      "esri/WebMap",
      "esri/views/MapView",
      "esri/config",
       "dojo/dom",
       "dojo/domReady!",
      "esri/Graphic",
      "esri/geometry/Point",
      "esri/symbols/SimpleMarkerSymbol"
    ], function(WebMap, MapView,esriConfig, dom,Graphic, Point, SimpleMarkerSymbol) {
 esriConfig.portalUrl="https://trail.arcgisonline.cn/portal";
      var webmap = new WebMap({
        portalItem: {
          id: "41618940f8764***8f98e38bf0b97ab9"
        }
      });

      var view = new MapView({
        container: "viewDiv",
        map: webmap
      });

      // Create a point
  var point = new Point({
    longitude: 111.173018,
    latitude: 26.888248
  });

 
  var markerSymbol = new SimpleMarkerSymbol({
    color: [226, 119, 40],
    outline: { 
      color: [255, 255, 255],
      width: 1
    }
  });
  
  // Create attributes
  var attributes = {
    Name: "I am a point", 
    Park: "Griffith Park", 
    City: "Los Angeles"  
  };
  
  // Create popup template
  var popupTemplate = {
    title: "{Name}",
    content: "I live in <b>{Park}</b> in the city of <b>{City}</b>."
  };

  // Create a graphic and add the geometry and symbol to it
  var pointGraphic = new Graphic({
    geometry: point,
    symbol: markerSymbol,
    attributes: attributes,
    popupTemplate: popupTemplate
  });
    
  view.graphics.add(pointGraphic);
    });
  </script>
mmexport1563611379144.jpg

要回复问题请先登录注册