<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
You have to wait until the map has loaded, because the viewer creates
the runtime map that you want to query.<br>
Once the map has loaded, you can access the runtime map, and set the
selection.<br>
<br>
You will need some javascript like this:<br>
<br>
<tt><span style="font-size: 10pt;">&lt;!-- Javascript part --&gt;</span></tt><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><br>
<tt>&lt;script type="text/javascript"&gt;</tt><br>
<tt>&nbsp;&nbsp;&nbsp; var mapFrame = null;&nbsp;&nbsp; // A reference to the
map frame</tt><br>
<tt>&nbsp;&nbsp;&nbsp; var originalMapFrameOnSelectionChanged = null // storage
for the original onSelectionChanged function</tt><br>
<tt>&nbsp;&nbsp;&nbsp; function OnSelectionChanged() // when something is
selected on the map</tt><br>
<tt>&nbsp;&nbsp;&nbsp; {</tt><br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert('Your handler works
perfectly');</tt><br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
originalMapFrameOnSelectionChanged();</tt><br>
<tt>&nbsp;&nbsp;&nbsp; }</tt><br>
<tt>&nbsp;&nbsp; </tt><br>
<tt>&nbsp;&nbsp;&nbsp; function InitDocument()</tt><br>
<tt>&nbsp;&nbsp;&nbsp; {</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var win =
document.getElementById('viewerFrame');</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (win.contentWindow) //FF returns
the actual tag, IE returns the iframe</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; win = win.contentWindow;</tt><br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mapFrameRef = win.GetMapFrame();</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; originalMapFrameOnSelectionChanged =
mapFrameRef.parent.OnSelectionChanged;</tt><br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mapFrameRef.parent.OnSelectionChanged =
OnSelectionChanged;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </tt><br>
<tt>&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; </tt><br>
<br>
<tt>&nbsp;&nbsp;&nbsp; function RetryInit()</tt><br>
<tt>&nbsp;&nbsp;&nbsp; {</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (mapFrame != null)</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; InitDocument();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; //At this point, you can post a "PageLoaded" via a form or
AJAX<br>
</tt> <tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; catch (e)</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mapFrame = null;</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </tt><br>
</span><tt><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if
(originalMapFrameOnSelectionChanged ==
null)</span></tt><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</tt><br>
<tt>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; mapFrame = null;</tt><br>
<tt>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; window.setTimeout("RetryInit();", 500);</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</tt></span><br>
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><tt>&lt;/script&gt;</tt><br>
<br>
<tt>&lt;!-- HTML part --&gt;</tt><br>
<tt>&lt;html&gt;</tt><br>
<tt>&lt;body&gt;</tt><br>
<tt>&nbsp;&nbsp;&nbsp; &lt;iframe id="viewerFrame"
frameborder="yes" width="100%" height="60%"
src="
src="../mapviewernet/dwfviewer.aspx?SESSION=&lt;%=sessionId%&gt;&amp;WEBLAYOUT=&lt;%=webLayout%&gt;""
onload="RetryInit()"&gt;&lt;/iframe&gt;</tt><br>
<tt>&lt;/body&gt;</tt><br>
<tt>&lt;/html&gt;</tt><br>
<br>
</span><br>
<pre class="moz-signature" cols="72">Regards. Kenneth, GEOGRAF A/S
</pre>
<br>
<br>
Nick Aizen skrev:
<blockquote
 cite="mid:C5302DE97C388A46AB9F6FA0B91AC81908DD45938C@AUSP01VMBX01.collaborationhost.net"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta name="Generator" content="Microsoft Word 12 (filtered medium)">
  <style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
  </style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
  <div class="Section1">
  <p class="MsoNormal">Can anyone help me with this process, I&#8217;m new to
both
web development and MapGuide API development, so please excuse me if I
don&#8217;t
ask my question the correct way but basically&#8230;.<o:p></o:p></p>
  <p class="MsoNormal">I want to be able to load a weblayout (created
in MG
Studio), &nbsp;when my asp.net page loads and query and zoom on the map in
the
weblayout before the page is fully displayed. Basically I will be
calling the
asp.net page from an application passing it parameters for the query
functionality.<o:p></o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal">&nbsp;I would appreciate it if someone can provide a
code
snippet. I&#8217;m using as my base, one of the examples provided on the
Autodesk web site. I can provide any information regarding the project
being
used if that will help. Also, other than the PDF&#8217;s provided my Autodesk
are there any helpful resources for developers?<o:p></o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal">Here&#8217;s the code when the page loads that loads a
weblayout:<o:p></o:p></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; <span
 style="color: rgb(43, 145, 175);">MgUserInformation</span>
userInfo = <span style="color: blue;">new</span> <span
 style="color: rgb(43, 145, 175);">MgUserInformation</span>(<span
 style="color: rgb(163, 21, 21);">"Administrator"</span>, <span
 style="color: rgb(163, 21, 21);">"admin"</span>);<o:p></o:p></span></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;&nbsp; <span
 style="color: rgb(43, 145, 175);">MgSite</span>
site = <span style="color: blue;">new</span> <span
 style="color: rgb(43, 145, 175);">MgSite</span>();<o:p></o:p></span></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;&nbsp;
site.Open(userInfo);<o:p></o:p></span></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><o:p>&nbsp;</o:p></span></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;&nbsp; <span
 style="color: rgb(43, 145, 175);">String</span>
sessionId = site.CreateSession();<o:p></o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;&nbsp;
  <span style="color: rgb(43, 145, 175);">String</span> webLayout = <span
 style="color: rgb(163, 21, 21);">"Library://DevTV/HelloWorld.WebLayout"</span>;<o:p></o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><o:p>&nbsp;</o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><o:p>&nbsp;</o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&#8216;Need
help with API to query and zoom&#8217;<o:p></o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><o:p>&nbsp;</o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><o:p>&nbsp;</o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><o:p>&nbsp;</o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">Then
the layout is passed to the viewer.<o:p></o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><o:p>&nbsp;</o:p></span></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;</span><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(163, 21, 21);">frameset</span><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span
 style="color: red;">rows</span><span style="color: blue;">="0,*"</span>
  <span style="color: red;">border</span><span style="color: blue;">="0"</span>
  <span style="color: red;">framespacing</span><span
 style="color: blue;">="0"&gt;<o:p></o:p></span></span></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; <span
 style="color: blue;">&lt;</span><span style="color: rgb(163, 21, 21);">frame</span>
  <span style="color: blue;">/&gt;<o:p></o:p></span></span></p>
  <p class="MsoNormal" style=""><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; <span
 style="color: blue;">&lt;</span><span style="color: rgb(163, 21, 21);">frame</span>
  <span style="color: red;">src</span><span style="color: blue;">="/mapguide2008/mapviewernet/ajaxviewer.aspx?SESSION=</span><span
 style="background: yellow none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">&lt;%</span>=
sessionId <span
 style="background: yellow none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">%&gt;</span><span
 style="color: blue;">&amp;WEBLAYOUT=</span><span
 style="background: yellow none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">&lt;%</span>=
webLayout <span
 style="background: yellow none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">%&gt;</span><span
 style="color: blue;">"</span> <span style="color: red;">name</span><span
 style="color: blue;">="ViewerFrame"</span>
  <span style="color: blue;">/&gt;<o:p></o:p></span></span></p>
  <p class="MsoNormal"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&lt;/</span><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(163, 21, 21);">frameset</span><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">&gt;</span><o:p></o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal">Many Thanks,<o:p></o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><b>Nick Aizen<o:p></o:p></b></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </div>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
  </pre>
</blockquote>
</body>
</html>