<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Create a Map from a JSON String? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412975#M38042</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much, Kelly!&amp;nbsp; I will test that and let you know how it turns out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Much appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Jan 2013 18:38:07 GMT</pubDate>
    <dc:creator>AlejandroVargas</dc:creator>
    <dc:date>2013-01-16T18:38:07Z</dc:date>
    <item>
      <title>How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412973#M38040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My ArcGIS Javascript application is run within a widget framework where widgets communicate using an event bus.&amp;nbsp; We have a widget which needs to perform certain tasks for a map viewer, but it cannot be contained in or shared code with the map viewer.&amp;nbsp; So the map viewer will use the widget framework's event bus to provide its map in JSON string format.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to create a Map instance based on this JSON string passed into my application.&amp;nbsp; How do I accomplish this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 04:11:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412973#M38040</guid>
      <dc:creator>AlejandroVargas</dc:creator>
      <dc:date>2013-01-15T04:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412974#M38041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alejandro,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use the esri.arcgis.utils.createMap method to build a map using input JSON. This JSON has to be in a particular format, see the doc here for details: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-web-map-json/"&gt;http://resources.arcgis.com/en/help/arcgis-web-map-json/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And see the help for a sample that shows this: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/ags_createwebmapitem"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/ags_createwebmapitem&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 16:59:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412974#M38041</guid>
      <dc:creator>KellyHutchins</dc:creator>
      <dc:date>2013-01-15T16:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412975#M38042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much, Kelly!&amp;nbsp; I will test that and let you know how it turns out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Much appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2013 18:38:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412975#M38042</guid>
      <dc:creator>AlejandroVargas</dc:creator>
      <dc:date>2013-01-16T18:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412976#M38043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Alejandro,&lt;BR /&gt;&lt;BR /&gt;You can use the esri.arcgis.utils.createMap method to build a map using input JSON. This JSON has to be in a particular format, see the doc here for details: &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-web-map-json/"&gt;http://resources.arcgis.com/en/help/arcgis-web-map-json/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And see the help for a sample that shows this: &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/ags_createwebmapitem"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/ags_createwebmapitem&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kelly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does the map have to be hosted on ArcGIS Online or Portal for ArcGIS?&amp;nbsp; I was hoping to have this work for a map whose services are hosted on a non-ArcGIS Online/Portal 10.1 ArcGIS Server, so the parameters described at &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#namespace_esri.arcgis.utils/esri.arcgis.utils.createMap"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#namespace_esri.arcgis.utils/esri.arcgis.utils.createMap&lt;/A&gt;&lt;SPAN&gt; wouldn't apply to what I need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this won't work, is there another way?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2013 21:55:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412976#M38043</guid>
      <dc:creator>AlejandroVargas</dc:creator>
      <dc:date>2013-01-16T21:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412977#M38044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No the map doesn't have to be hosted on arcgis online. If you look at the sample I linked you'll see that we define the web map as follows - note that the urls to the map layers could point to your services. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
webmap.itemData = {
"operationalLayers": [{
"url":layerURL,
"visibility": true,
"opacity": 0.75,
"title": "Soil Survey Map",
"itemId": "204d94c9b1374de9a21574c9efa31164"
}],
"baseMap": {
"baseMapLayers": [{
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer"
},{
"isReference": true,
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer"
}],
"title": "World_Terrain_Base"
},
"version": "1.1"
};


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:44:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412977#M38044</guid>
      <dc:creator>KellyHutchins</dc:creator>
      <dc:date>2021-12-11T18:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412978#M38045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Kelly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I should have mentioned this before, but I plan on printing the map after receiving its JSON representation.&amp;nbsp; A Flex map viewer will pass a JSON map to a javascript widget, which will use a PrintTask to submit a print job to the backend print server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Will the webmaps you previously described work with 10.1 printing using javascript?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-web-map-json/"&gt;http://resources.arcgis.com/en/help/arcgis-web-map-json/&lt;/A&gt;&lt;SPAN&gt;, there is a tidbit that reads,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;The web map and its specification should not be confused with the ExportWebMap specification, which is used by ArcGIS Server when printing maps. Although you may notice similarities in properties, they are two different specifications.&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In short, if what we discussed previously won't work for printing a map from javascript, how can I accomplish this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2013 03:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412978#M38045</guid>
      <dc:creator>AlejandroVargas</dc:creator>
      <dc:date>2013-02-06T03:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412979#M38046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;No the map doesn't have to be hosted on arcgis online. If you look at the sample I linked you'll see that we define the web map as follows - note that the urls to the map layers could point to your services. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
webmap.itemData = {
"operationalLayers": [{
"url":layerURL,
"visibility": true,
"opacity": 0.75,
"title": "Soil Survey Map",
"itemId": "204d94c9b1374de9a21574c9efa31164"
}],
"baseMap": {
"baseMapLayers": [{
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer"
},{
"isReference": true,
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer"
}],
"title": "World_Terrain_Base"
},
"version": "1.1"
};


&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kelly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tried this code, but the Promise returned from &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;esri.arcgis.utils.createMap(webmap, "map");&lt;/PRE&gt;&lt;SPAN&gt; never invokes the success or failure events.&amp;nbsp; Below I have listed my code used.&amp;nbsp; Also, I have listed below my code a sample of the JSON provided to this print widget.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you offer any insight as to why &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;esri.arcgis.utils.createMap(webmap, "map");&lt;/PRE&gt;&lt;SPAN&gt; is not working?&amp;nbsp; I appreciate your prompt reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
/**
*
* Invoked when Flex viewer sends JSON map via event bus.
*
* @param data - JSON map
*/
function mapDataReceived(data) {

&amp;nbsp;&amp;nbsp;&amp;nbsp; var webmap = {};
&amp;nbsp;&amp;nbsp;&amp;nbsp; webmap.item = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "title":"Soil Survey Map of USA",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "snippet": "Detailed description of data",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "extent": data.mapOptions.extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; };

&amp;nbsp;&amp;nbsp;&amp;nbsp; webmap.itemData = data;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapPromise = esri.arcgis.utils.createMap(webmap, "map");
&amp;nbsp;&amp;nbsp;&amp;nbsp; var map;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapPromise.then(mapCreationSuccess, mapCreationFailed);
}

function mapCreationSuccess(response) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var map = response.map;

&amp;nbsp;&amp;nbsp;&amp;nbsp; var printTask = new esri.tasks.PrintTask(config.EXPORT_WEBMAP_URL);


&amp;nbsp;&amp;nbsp;&amp;nbsp; //TODO Change template to user options.
&amp;nbsp;&amp;nbsp;&amp;nbsp; var template = new esri.tasks.PrintTemplate();
&amp;nbsp;&amp;nbsp;&amp;nbsp; template.exportOptions = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width: 500,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height: 400,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dpi: 96
&amp;nbsp;&amp;nbsp;&amp;nbsp; };
&amp;nbsp;&amp;nbsp;&amp;nbsp; template.format = "PDF";
&amp;nbsp;&amp;nbsp;&amp;nbsp; template.layout = "MAP_ONLY";
&amp;nbsp;&amp;nbsp;&amp;nbsp; template.preserveScale = false;


&amp;nbsp;&amp;nbsp;&amp;nbsp; var params = new esri.tasks.PrintParameters();
&amp;nbsp;&amp;nbsp;&amp;nbsp; params.map = map;
&amp;nbsp;&amp;nbsp;&amp;nbsp; params.template = template;

&amp;nbsp;&amp;nbsp;&amp;nbsp; printTask.execute(params, printResult, printError);
}

function mapCreationFailed(error) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.error("Unable to create map.");

}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;JSON provided to mapDataReceived(..)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
{
"exportOptions": {
"outputSize":[892,550]},
"mapOptions": {
"scale":141344140.17757848,
"extent": {
"ymin":-92.48878923766816,
"ymax":92.48878923766816,
"xmax":150,
"spatialReference": {
"wkid":4326
},
"xmin":-150}
},
"operationalLayers": [{
"url":"https://IPAddressToArcGISServer/arcgis/rest/services/ServiceName/MapServer",
"title":"BaseMap",
"id":"BaseMap"
}],
"layoutOptions": {
"legendOptions": {
"operationalLayers": [{
"id":"BaseMap"
}]}}}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:44:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412979#M38046</guid>
      <dc:creator>AlejandroVargas</dc:creator>
      <dc:date>2021-12-11T18:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412980#M38047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I ran a quick test using a simple map with just a basemap. Here's the jsfiddle showing the code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://jsfiddle.net/gppby/"&gt;http://jsfiddle.net/gppby/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The web map doc has several examples of valid json that you can also use to test with : &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-web-map-json/#/Web_map_format_overview/02qt00000007000000/"&gt;http://resources.arcgis.com/en/help/arcgis-web-map-json/#/Web_map_format_overview/02qt00000007000000/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 17:38:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412980#M38047</guid>
      <dc:creator>KellyHutchins</dc:creator>
      <dc:date>2013-02-11T17:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a Map from a JSON String?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412981#M38048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for including your jsFiddle code.&amp;nbsp; I noticed there is a significant difference between your JSON format and mine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like your JSON format follows the guidelines listed at &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-web-map-json/#/Web_map_data/02qt0000000q000000/"&gt;http://resources.arcgis.com/en/help/arcgis-web-map-json/#/Web_map_data/02qt0000000q000000/&lt;/A&gt;&lt;SPAN&gt; while mine follows the ExportWebMapSpecification JSON format &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//0154000004w8000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//0154000004w8000000&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As my Flex viewer is providing its map in ExportWebMap specification format, is there an easy way for ArcGIS API for Flex to get the 'web map data' JSON format of a map rather than its ExportWebMap specification?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 19:35:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-create-a-map-from-a-json-string/m-p/412981#M38048</guid>
      <dc:creator>AlejandroVargas</dc:creator>
      <dc:date>2013-02-11T19:35:27Z</dc:date>
    </item>
  </channel>
</rss>

