I hope this question isn't too broad, but there's a LOT of unfamiliar syntax happening in this particular require.js/ESRI example, and I am hoping someone can explain some of this to me.
First, this code works (that is, it does what I expect it to do): it creates a base map and adds a FeatureLayer pulled from a map service. It's a stripped-down version of an example from the ESRI Javascript API page. Here's the code:
var map;
var featureLayer;
require(["esri/map", "dojo/domReady!", "esri/layers/FeatureLayer"], function (Map) {
map = new Map("map", {
basemap: "topo",
center: [-100.195, 39.567], // long, lat
zoom: 4
});
featureLayer = new esri.layers.FeatureLayer(
"http://my-server-url.com/arcgis/rest/services/Projects/MapServer/0",
{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND
}
);
map.addLayer(featureLayer);
});
Now for the particular questions:
What is this require([...], function(args) { } syntax doing? I don't even know how to read this. Is it a function call to require.js? What goes in the square brackets? What are the function arguments?
From other examples, it looks like there normally should be one function argument per include in the require.js call. But here, if I add an argument for FeatureLayer, it doesn't work.
The "dojo/domReady!" include doesn't seem to ever have a corresponding argument in any example. Is this related to the exclamation point? What does the exclamation point mean?
Can anyone point me to a USEFUL require.js reference? The requirejs.org website reads more like a tech spec than a user manual. And the ESRI website seems to assume you know how to use require.
And yes, I have been Googling--the problem is that Google isn't great at searching for computer syntax questions since it strips punctuation, and because "require javascript syntax" and the like make for crappy (over-broad) search terms.