AnsweredAssumed Answered

map vs app.map

Question asked by jay.kapalczynski on Mar 24, 2014
Latest reply on Mar 24, 2014 by JUihlein-esristaff
Confused here...working on integrating a couple examples...

one references map and the other one app.map

https://developers.arcgis.com/javascript/jssamples/widget_print_esri_request.html
app.map = new esri.Map("map", {           basemap: "hybrid",           center: [-117.447, 33.906],           zoom: 17,           slider: false         });


https://developers.arcgis.com/javascript/jssamples/widget_basemap.html
map = new Map("map", {           basemap: "topo",           center: [-105.255, 40.022],           zoom: 13         });


I have the example with app.map working () but I then try and bring in the Basemap gallery and that one only has map referenced...how do I modify this to work
THE basemap selector appears but when I select a map nothing happens.
I tried this

var basemapGallery = new BasemapGallery({       showArcGISBasemaps: true,       app.map: map     }, "basemapGallery");      basemapGallery.startup();


    var basemapGallery = new BasemapGallery({       showArcGISBasemaps: true,       map: map     }, "basemapGallery");      basemapGallery.startup();      basemapGallery.on("error", function(msg) {       console.log("basemap gallery error:  ", msg);     });



 var map;     var app = {};     require([         "dojo/ready",         "dojo/on",         "dojo/_base/connect",         "dojo/dom",         "dojo/dom-construct",         "dojo/parser",         "dijit/registry",         "esri/layers/FeatureLayer",      "esri/layers/ArcGISDynamicMapServiceLayer",      "esri/InfoTemplate",         "esri/renderers/UniqueValueRenderer",         "esri/renderers/SimpleRenderer",         "esri/symbols/SimpleMarkerSymbol",         "esri/symbols/SimpleLineSymbol",   "dijit/layout/BorderContainer",   "dijit/layout/ContentPane",   "esri/map",   "esri/dijit/BasemapGallery",   "esri/request",   "esri/config",         "dojo/_base/array",   "esri/dijit/Print",   "esri/tasks/PrintTemplate",   "esri/arcgis/utils",   "esri/domUtils",   "esri/dijit/Popup",   "dojo/domReady!"     ], function(         ready,         on,         connect,         dom,         domConstruct,         parser,         registry,         FeatureLayer,      ArcGISDynamicMapServiceLayer,      InfoTemplate,      UniqueValueRenderer,      SimpleRenderer,      SimpleMarkerSymbol,      SimpleLineSymbol,         BorderContainer,         ContentPane,         Map,         BasemapGallery,         esriRequest,         esriConfig,         arrayUtils,         Print,         PrintTemplate,         arcgisUtils,         domUtils,         Popup     ) {  //ready(function(){      parser.parse();      //setup event handlers for the next/previous buttons     on(dom.byId("previous"), "click", selectPrevious);     on(dom.byId("next"), "click", selectNext);      esri.config.defaults.io.proxyUrl = "https://junk.gov/proxypage_net/proxy.ashx";       app.map = new esri.Map("map", {        basemap: "topo",        center: [-77.4329, 37.5410],        zoom: 7,        slider: false     });      // add graphics for pools with permits     var permitUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/MapServer/1";     var poolFeatureLayer = new FeatureLayer(permitUrl, {       mode: FeatureLayer.MODE_SNAPSHOT     });     app.map.addLayer(poolFeatureLayer);      var TestUrl2 = "https://map.gov/arcgis/rest/services/Map/Map_Readonly/FeatureServer/0";     var FeatureLayer2 = new FeatureLayer(TestUrl2, {       mode: FeatureLayer.MODE_SNAPSHOT     });     app.map.addLayer(FeatureLayer2);      //add the basemap gallery, in this case we'll display maps from ArcGIS.com including bing maps  var basemapGallery = new BasemapGallery({  showArcGISBasemaps: true,  map: map  }, "basemapGallery");  basemapGallery.startup();      basemapGallery.on("error", function(msg) {       console.log("basemap gallery error:  ", msg);     });    });  

Outcomes