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.
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>
The graphics aren't displaying because you are adding points to the map in lat/lon which works fine if your map has a Web Mercator or Geographic spatial reference. However your map's spatial reference is 2943 (matches your dynamic layer) so you'll need to project the points before adding them to the map. Here's a fiddle that shows how this would work:
The graphics aren't displaying because you are adding points to the map in lat/lon which works fine if your map has a Web Mercator or Geographic spatial reference. However your map's spatial reference is 2943 (matches your dynamic layer) so you'll need to project the points before adding them to the map. Here's a fiddle that shows how this would work: