Select to view content in your preferred language

new Map() versus arcgisUtils.createMap()

2956
2
Jump to solution
04-03-2014 05:37 AM
DavidKimball1
Occasional Contributor
This is a pretty basic question, but I haven't been able to find an answer after much searching.

I want to create a map in my custom Javascript API application from an ArcGIS.com web map. I have tried the following methods:

arcgisUtils.createMap(webmapid, "mapDiv").then(function (response) {map = response.map;});


and

map = new Map("mapDiv", {  basemap: "topo",  autoResize: false, // see http://forums.arcgis.com/threads/90825-Mobile-Sample-Fail  center: [-71.7, 42.35],  zoom: 8,  minZoom: 7,  logo: false,  slider: true,  sliderStyle: "small" });


The first one creates a map using my ArcGIS.com web map. The second one creates an empty map (basemap only) with a bunch of attributes I need (autoResize:false to deal with a map resize bug, etc). I want to do both - use my webmap and assign all those attributes to the map. How can I do this? Why are there two ways to create a map?

Thanks,

David
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Esri Frequent Contributor
arcgis.Utils.createmap takes a third options parameter.
https://developers.arcgis.com/javascript/jsapi/esri.arcgis.utils-amd.html#createmap

It looks a little odd at first, but you can do the following:
var mapOptions = {  basemap: "topo",  autoResize: false, // see http://forums.arcgis.com/threads/90825-Mobile-Sample-Fail  center: [-71.7, 42.35],  zoom: 8,  minZoom: 7,  logo: false,  slider: true,  sliderStyle: "small" }); arcgisUtils.createMap(webmapid, "mapDiv", { mapOptions: mapOptions }).then(function (response) {map = response.map;});


That should do what you're looking for.

View solution in original post

0 Kudos
2 Replies
ReneRubalcava
Esri Frequent Contributor
arcgis.Utils.createmap takes a third options parameter.
https://developers.arcgis.com/javascript/jsapi/esri.arcgis.utils-amd.html#createmap

It looks a little odd at first, but you can do the following:
var mapOptions = {  basemap: "topo",  autoResize: false, // see http://forums.arcgis.com/threads/90825-Mobile-Sample-Fail  center: [-71.7, 42.35],  zoom: 8,  minZoom: 7,  logo: false,  slider: true,  sliderStyle: "small" }); arcgisUtils.createMap(webmapid, "mapDiv", { mapOptions: mapOptions }).then(function (response) {map = response.map;});


That should do what you're looking for.
0 Kudos
DavidKimball1
Occasional Contributor
Great, it works! Thanks! Not sure how I missed that 🙂
0 Kudos