官术网_书友最值得收藏!

The map object

Now that we have the components, we need to create an interactive map; let's put them together. We'll start by constructing a map object, which provides the basis and interaction platform that we'll need to work with. The map constructor takes two arguments. The first parameter, either the HTML node or the id string of a node, indicates where we want to put our map. The second parameter of the map constructor is an options object, where we add the configurable options that make our map work as expected:

function (
    Map, ArcGISDynamicMapServiceLayer,
    IdentifyParameters, IdentifyTask, InfoTemplate,
    arrayUtils
  ) {
 var map = new Map("map", {
 basemap: "national-geographic",
 center: [-95, 45],
 zoom: 3
 });
  });

In the preceding code, we're creating a map in the div element with an id of map. In the map, we're adding a basemap, or a background reference map, in the style of National Geographic. We're centering the map at 45°N and 95°W, at a zoom level of three. We'll go into greater depth concerning these configurations in later chapters. If you're using a desktop browser to view the results, you should see the United States, including Alaska, and Hawaii, as in the following image:

The map object

Tip

If you have experience working with Dojo, most element constructors have the options first, followed by the node or the id of the node. This is the reverse of how we construct a map. Remember, order is important.

主站蜘蛛池模板: 宜宾县| 玛曲县| 阿克苏市| 汕头市| 霞浦县| 凉城县| 儋州市| 二连浩特市| 开化县| 安宁市| 读书| 琼海市| 中卫市| 沭阳县| 贵德县| 吴江市| 屯昌县| 永州市| 扎囊县| 新竹县| 冕宁县| 石屏县| 曲水县| 靖远县| 仙居县| 石家庄市| 棋牌| 施秉县| 曲靖市| 苍山县| 武义县| 开封县| 金山区| 普兰店市| 磴口县| 平罗县| 肥乡县| 庐江县| 沁水县| 府谷县| 阳山县|