<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to dynamically load map APIs</title>
	<atom:link href="http://code.davidjanes.com/blog/2008/11/08/how-to-dynamically-load-map-apis/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.davidjanes.com/blog/2008/11/08/how-to-dynamically-load-map-apis/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 07 Aug 2010 21:58:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ricky Brundritt</title>
		<link>http://code.davidjanes.com/blog/2008/11/08/how-to-dynamically-load-map-apis/comment-page-1/#comment-12779</link>
		<dc:creator>Ricky Brundritt</dc:creator>
		<pubDate>Fri, 21 May 2010 16:40:45 +0000</pubDate>
		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=140#comment-12779</guid>
		<description>Just got a report from someone sawing that the solution for Bing Maps causes the compass for panning to stop working.</description>
		<content:encoded><![CDATA[<p>Just got a report from someone sawing that the solution for Bing Maps causes the compass for panning to stop working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arian Hojat</title>
		<link>http://code.davidjanes.com/blog/2008/11/08/how-to-dynamically-load-map-apis/comment-page-1/#comment-9910</link>
		<dc:creator>Arian Hojat</dc:creator>
		<pubDate>Tue, 23 Feb 2010 15:40:03 +0000</pubDate>
		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=140#comment-9910</guid>
		<description>Saw your useful post. I made a function to use jquery to do almost same task, using lazy loading in the background instead of waiting 2-2.5seconds for the libs to load in  (think your above example will load dynamically, but still take time since its not asynchronous and takes place in , right?) ...

function loadVirtualEarthLibs(onScriptLoadFunc){ //lazy-loading in background, pass onScriptLoad function name if needed
   
  if (window.VEMap){ return; } //already loaded, dont need to download/run script again

  var compat_script_url = &quot;http://dev.virtualearth.net/mapcontrol/v6.2/js/atlascompat.js&quot;;
  var main_script_url = &quot;https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&amp;mkt=en-us&amp;s=1&quot;+ ((onScriptLoadFunc)? (&quot;&amp;onScriptLoad=&quot;+onScriptLoadFunc) : &quot;&quot;);

  if (!(window.attachEvent)) {
      $.ajax({ type: &quot;GET&quot;, url: compat_script_url, success: function(){ 
        $.ajax({ type: &quot;GET&quot;, url: main_script_url, success: function(){ }, dataType: &quot;script&quot;, cache: true });
      }, dataType: &quot;script&quot;, cache: true });
  } else {
    $.ajax({ type: &quot;GET&quot;, url: main_script_url, success: function(){ }, dataType: &quot;script&quot;, cache: true });
  }
   
}

so i set that with jquery on document.ready...

$(function(){
loadVirtualEarthLibs();
});

And then later on when my &quot;ajax questionnaire&quot; is done, a Bing map is dynamically loaded ...

  if (!window.VEMap) { // I make sure again when i actually need to use my library, if its available. if not, try to get it again (edge case/unlikely), otherwise just build the map. should be quick since library was loaded while you were reading the page.
    loadVirtualEarth(&#039;initMap&#039;);
  } else {
    initMap();
  }

... and the initMap is just initialization code for building the map

function initMap()
{
    try
    {
        map = new VEMap(&#039;map_canvas&#039;);
... 

}</description>
		<content:encoded><![CDATA[<p>Saw your useful post. I made a function to use jquery to do almost same task, using lazy loading in the background instead of waiting 2-2.5seconds for the libs to load in  (think your above example will load dynamically, but still take time since its not asynchronous and takes place in , right?) &#8230;</p>
<p>function loadVirtualEarthLibs(onScriptLoadFunc){ //lazy-loading in background, pass onScriptLoad function name if needed</p>
<p>  if (window.VEMap){ return; } //already loaded, dont need to download/run script again</p>
<p>  var compat_script_url = &#8220;http://dev.virtualearth.net/mapcontrol/v6.2/js/atlascompat.js&#8221;;<br />
  var main_script_url = &#8220;https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&amp;mkt=en-us&amp;s=1&#8243;+ ((onScriptLoadFunc)? (&#8220;&amp;onScriptLoad=&#8221;+onScriptLoadFunc) : &#8220;&#8221;);</p>
<p>  if (!(window.attachEvent)) {<br />
      $.ajax({ type: &#8220;GET&#8221;, url: compat_script_url, success: function(){<br />
        $.ajax({ type: &#8220;GET&#8221;, url: main_script_url, success: function(){ }, dataType: &#8220;script&#8221;, cache: true });<br />
      }, dataType: &#8220;script&#8221;, cache: true });<br />
  } else {<br />
    $.ajax({ type: &#8220;GET&#8221;, url: main_script_url, success: function(){ }, dataType: &#8220;script&#8221;, cache: true });<br />
  }</p>
<p>}</p>
<p>so i set that with jquery on document.ready&#8230;</p>
<p>$(function(){<br />
loadVirtualEarthLibs();<br />
});</p>
<p>And then later on when my &#8220;ajax questionnaire&#8221; is done, a Bing map is dynamically loaded &#8230;</p>
<p>  if (!window.VEMap) { // I make sure again when i actually need to use my library, if its available. if not, try to get it again (edge case/unlikely), otherwise just build the map. should be quick since library was loaded while you were reading the page.<br />
    loadVirtualEarth(&#8216;initMap&#8217;);<br />
  } else {<br />
    initMap();<br />
  }</p>
<p>&#8230; and the initMap is just initialization code for building the map</p>
<p>function initMap()<br />
{<br />
    try<br />
    {<br />
        map = new VEMap(&#8216;map_canvas&#8217;);<br />
&#8230; </p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://code.davidjanes.com/blog/2008/11/08/how-to-dynamically-load-map-apis/comment-page-1/#comment-32</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Mon, 10 Nov 2008 15:53:41 +0000</pubDate>
		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=140#comment-32</guid>
		<description>Thank you!</description>
		<content:encoded><![CDATA[<p>Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Janes&#8217; Code Weblog &#187; Adding MapField to inputEx</title>
		<link>http://code.davidjanes.com/blog/2008/11/08/how-to-dynamically-load-map-apis/comment-page-1/#comment-23</link>
		<dc:creator>David Janes&#8217; Code Weblog &#187; Adding MapField to inputEx</dc:creator>
		<pubDate>Sun, 09 Nov 2008 11:21:18 +0000</pubDate>
		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=140#comment-23</guid>
		<description>[...] Mapping APIs are dynamically loaded [...]</description>
		<content:encoded><![CDATA[<p>[...] Mapping APIs are dynamically loaded [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SoulSolutions</title>
		<link>http://code.davidjanes.com/blog/2008/11/08/how-to-dynamically-load-map-apis/comment-page-1/#comment-22</link>
		<dc:creator>SoulSolutions</dc:creator>
		<pubDate>Sun, 09 Nov 2008 03:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=140#comment-22</guid>
		<description>Another awesome article - great work!</description>
		<content:encoded><![CDATA[<p>Another awesome article &#8211; great work!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
