0

我需要在我的 arcgis 地图集成中正确实施 Graphic 和 GraphicLayer 的解释

    { <script src="https://js.arcgis.com/4.12/"></script>
      <script>
       require([
        "esri/Map",
        "esri/graphic",
        "esri/views/MapView",
        "esri/geometry/Point",
        "esri/graphic",
        "esri/symbols/PictureMarkerSymbol",
        "esri/layers/GraphicsLayer",
        "esri/dijit/BasemapToggle",
        "esri/dijit/HomeButton"],
         function (Map, MapView, Point, Graphic, GraphicsLayer, 
              PictureMarkerSymbol) {

         var map = new Map({
             basemap: "hybrid"

         });
         on(map, "load",addgraphics);

         var view = new MapView({
            container: "viewDiv",
            map: map,
            center: [72.952335,19.180190],
            zoom: 15
        });

        var marker = new PictureMarkerSymbol('http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png', 32, 32);

        function addgraphics(){
            var markerPoint = new Point([72.952335,19.180190]);
            var storepoint = new Graphic(markerPoint,marker);
            var layer = new GraphicsLayer();
            layer.add(storepoint);
            view.addLayer(layer);

        }

    });

}

我希望输出应该是带有指定纬度和经度上的标记的地图。输出是空白,我认为这是错误的。

4

1 回答 1

0

检查这个例子。https://codepen.io/mcantonbul/pen/vYBdVmQ

错误是图层被添加到“地图”对象,而不是“地图视图”对象。

view.addLayer(layer);

map.add(layer);

var markerPoint = new Point([72.952335,19.180190]);

var markerPoint = new Point({x:72.952335,y:19.180190});
于 2019-09-09T06:45:18.613 回答