AnsweredAssumed Answered

Adding points on a dynamic map problem

Question asked by sailitang on Sep 5, 2013
Latest reply on Sep 6, 2013 by sailitang
Hi,

This is my code. I would like to add a point to my dynamic map, but it doesn't work and nothing is on my map. I don't know if map.graphics.add(graphic) works on dynamic map? If not, for dynamic map, how to add a point? Thanks.

<script>
      var map;
require([
        "esri/map", "esri/geometry/Point",
        "esri/symbols/SimpleMarkerSymbol", "esri/graphic",
        "dojo/_base/array", "dojo/dom-style", "dojox/widget/ColorPicker",
        "esri/layers/ArcGISDynamicMapServiceLayer", "dojo/domReady!"
      ], function(
        Map, Point,
        SimpleMarkerSymbol, Graphic,
        arrayUtils, domStyle, ColorPicker, ArcGISDynamicMapServiceLayer
      ) {

        map = new Map("map");
       
        var basemaplayer = new ArcGISDynamicMapServiceLayer(
          "http://dnr-mrn-wms.gnb.ca/arcgisproxy/rest/services/BMS_Proxy_Test/MapServer");
          map.addLayer(basemaplayer);
       
        map.on("load", mapLoaded);
     
        function mapLoaded(){
          var points = [[-66.653, 45.967]];
          var initColor = "#ce641d";
          arrayUtils.forEach(points, function(point) {
            var graphic = new Graphic(new Point(point), createSymbol(initColor));
            map.graphics.add(graphic);
          });    
         
        };
       
        function createSymbol(color){
          var markerSymbol = new esri.symbol.SimpleMarkerSymbol();
         
          markerSymbol.setColor(new dojo.Color(color));
          markerSymbol.setOutline(null);
          return markerSymbol;
        };
      });
    </script>

Outcomes