Hi, I tried running your code, seems it's trying to access an unavailable ArcGISOnline item. The code adding the graphic seems to be working fine, I tried the snippet with the geocoder sample. Also jshint says there's a stray bracket in the end of the adding graphic snippet, the updated code:
require([
"dojo/parser",
"dojo/ready",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/dom",
"esri/map",
"esri/urlUtils",
"esri/arcgis/utils",
"esri/dijit/Legend",
"esri/dijit/Scalebar",
"esri/dijit/Geocoder",
"esri/graphic",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/PictureMarkerSymbol",
"esri/geometry/screenUtils",
//"dojo/dom",
"dojo/dom-construct",
"dojo/query",
"dojo/_base/Color",
"dojo/domReady!"
], function(
parser,
ready,
BorderContainer,
ContentPane,
dom,
Map,
urlUtils,
arcgisUtils,
Legend,
Scalebar,
Geocoder,
Graphic,
SimpleMarkerSymbol,
PictureMarkerSymbol,
screenUtils,
//dom,
domConstruct,
query,
Color
) {
//create a map and instance of geocoder and other widgets here
ready(function(){
parser.parse();
arcgisUtils.createMap("**WEB map id here**","mapDiv").then(function(response){
//update the app
dom.byId("title").innerHTML = response.itemInfo.item.title;
dom.byId("subtitle").innerHTML = response.itemInfo.item.snippet;
var actualmap = response.map;
//add the scalebar
var scalebar = new Scalebar({
map: actualmap,
scalebarUnit: "english"
});
//add the legend. Note that we use the utility method getLegendLayers to get
//the layers to display in the legend from the createMap response.
var legendLayers = arcgisUtils.getLegendLayers(response);
var legendDijit = new Legend({
map: actualmap,
layerInfos: legendLayers
},"legend");
legendDijit.startup();
//geocoder
geocoder = new Geocoder({
map: actualmap,
autoComplete: true,
arcgisGeocoder: false,
geocoders: [{
"name": "geocoder name",
"url": "*geocoder url here*",
"countryCode":"USA",
"currentExtent":false,
"placeholder": "Search",
"singleLineFieldName":"SingleLine"
}],
},"search");
geocoder.startup();
geocoder.focus();
//show results of geocoder on map *CODE copied from ArcGIS Tutorial to add point****
geocoder.on("select", showLocation);
function showLocation(evt) {
map.graphics.clear();
var point = evt.result.feature.geometry;
var symbol = new SimpleMarkerSymbol()
.setStyle("square")
.setColor(new Color([255,0,0,0.5]));
var graphic = new Graphic(point, symbol);
map.graphics.add(graphic);
}
});
});
});
Sorry I couldn't be more help. Good luck!
... View more