<?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: Changing Map Service Dynamically in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549270#M12392</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gaurav,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Try this map.removeAllLayers and then map.lods=[]; and then add the new layers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Sep 2010 11:11:40 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2010-09-02T11:11:40Z</dc:date>
    <item>
      <title>Changing Map Service Dynamically</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549266#M12388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What I have is a combo-box that I have populated with names of different maps that I have and added the tiled map service-urls to the data field. At the combo-box close event, I am trying to load the selected map. In essence, this is to change the map service dynamically at run time because I think that loading all my maps initially and hiding/showing them would be wasteful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that, while my map loads the first map that I select, it fails to load the subsequent maps. As far as I understand it, it is just the problem of changing the extent and LODs of the map. But, despite all my efforts, I am not being able to obtain the extent of the map whose url I obtain from the combo box. I have seen trails of people looking for a solution to similar problems on the net, but could not find any crisp solutions. I can't believe something this basic can be impossible for an API this robust.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone please bail me out. A little pointer in the right direction too would be highly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gaurav&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Aug 2010 12:10:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549266#M12388</guid>
      <dc:creator>FlexDeveloper</dc:creator>
      <dc:date>2010-08-31T12:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Map Service Dynamically</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549267#M12389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gaurav,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Why not predefine the extent of the map service in the combobox data?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//Populate your combobox with an array like this.
private var ABC:ArrayCollection = new ArrayCollection([{label:"Subway", msurl:"the map service url",extent:"-78.75651009240596,39.6278291354036,-78.74282009759395,39.634491742596595"},
&amp;nbsp;&amp;nbsp;&amp;nbsp; {label:"CiCi's Pizza", msurl:"the map service url", extent:"-78.84485849540602,39.6282293839035,-78.831168500594,39.634891991096495"},
&amp;nbsp;&amp;nbsp;&amp;nbsp; {label:"Auntie Anne's", msurl:"the map service url", extent:"-78.84208596390596,39.623430996403556,-78.82839596909395,39.63009360359655"},
&amp;nbsp;&amp;nbsp;&amp;nbsp; {label:"Orange Julius", msurl:"the map service url", extent:"-78.841786340406,39.6244109709035,-78.82809634559399,39.63107357809649"}]);

//Then you get access to the extent using some code like this:

var ext:String = yourComboboxId.dataProvider[yourComboboxId.selectedIndex].extent;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:45:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549267#M12389</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T23:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Map Service Dynamically</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549268#M12390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear Robert,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a heap. But this is leading me into further troubles. Actually I have one service published for each state of the country. And since states vary greatly in size, I had to set different LODs for each map. And if I go by your example, I shall have to load the LODs from the combo-box data too.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Right now, the way I am doing it is to initialize each map service with a unique id in the beginning, but this has started to play havoc on our server. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As I mentioned before, one thing that I noticed is that if I load just one blank map in the beginning and provide the service URL later on through the combo-box, the map automatically extracts its full extents and shows it properly. My question is, why can we not do it for the URLs that we pass later on? Is there not a way to reset or re-initialize the map before the next URL is passed. I tried the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;myMap.initialize()&lt;/SPAN&gt;&lt;SPAN&gt; function, but it does not seem to have the desired effect. Or maybe destroy the myMap altogether and recreate one at each combo-box change event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another way of asking the above question is that if I can get hold of a map-service URL, say, as a user input, how do I go about displaying it in my application without having to hard-code each of the parameters like fullExtent and LODs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I shall be very thankful for any help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gaurav&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Sep 2010 06:01:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549268#M12390</guid>
      <dc:creator>FlexDeveloper</dc:creator>
      <dc:date>2010-09-02T06:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Map Service Dynamically</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549269#M12391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks to Robert again, I atleast found the answer to the question:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Dear Robert,&lt;BR /&gt;Another way of asking the above question is that if I can get hold of a map-service URL, say, as a user input, how do I go about displaying it in my application without having to hard-code each of the parameters like fullExtent and LODs.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Robert has very beautifully illustrated the solution in a separate thread at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV align="center"&gt;&lt;A href="http://forums.esri.com/thread.asp?c=158&amp;amp;f=2421&amp;amp;t=293581"&gt;http://forums.esri.com/thread.asp?c=158&amp;amp;f=2421&amp;amp;t=293581&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;However, trying this code too, my problem persists. The map loads the first URL that is provided but refuses to load the other URLs because they come from different extents (though they have the same projection). I tried to set the map extent using the &lt;STRONG&gt;myMap.extent= typeXML.initialExtent;&lt;/STRONG&gt; and the LODs using &lt;STRONG&gt;map.lods = typeXML.tileInfo.lods;&lt;/STRONG&gt; but still am not able to get the new map to display. I wonder where I am getting wrong. I even tried to destroy the map and re-create a new one, but got mixed up in that.&lt;BR /&gt;&lt;BR /&gt;Robert, please be my savior.:)&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Gaurav&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Sep 2010 09:33:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549269#M12391</guid>
      <dc:creator>FlexDeveloper</dc:creator>
      <dc:date>2010-09-02T09:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Map Service Dynamically</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549270#M12392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gaurav,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Try this map.removeAllLayers and then map.lods=[]; and then add the new layers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Sep 2010 11:11:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/changing-map-service-dynamically/m-p/549270#M12392</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2010-09-02T11:11:40Z</dc:date>
    </item>
  </channel>
</rss>

