[mapguide-users] Newbie needs help with project to query web layouts

Kenneth, GEOGRAF A/S ks at geograf.dk
Fri May 2 02:53:17 EDT 2008


You have to wait until the map has loaded, because the viewer creates 
the runtime map that you want to query.
Once the map has loaded, you can access the runtime map, and set the 
selection.

You will need some javascript like this:

<!-- Javascript part -->
<script type="text/javascript">
    var mapFrame = null;   // A reference to the map frame
    var originalMapFrameOnSelectionChanged = null // storage for the 
original onSelectionChanged function
    function OnSelectionChanged() // when something is selected on the map
    {
        alert('Your handler works perfectly');
        originalMapFrameOnSelectionChanged();
    }
  
    function InitDocument()
    {
        var win = document.getElementById('viewerFrame');
        if (win.contentWindow) //FF returns the actual tag, IE returns 
the iframe
          win = win.contentWindow;
        mapFrameRef = win.GetMapFrame();
        originalMapFrameOnSelectionChanged = 
mapFrameRef.parent.OnSelectionChanged;
        mapFrameRef.parent.OnSelectionChanged = 
OnSelectionChanged;             
    }  

    function RetryInit()
    {
        if (mapFrame != null)
            return;
           
        try
        {
            InitDocument();
            //At this point, you can post a "PageLoaded" via a form or AJAX
        }
        catch (e)
        {
            mapFrame = null;
        }
       
        if (originalMapFrameOnSelectionChanged == null)
        {
            mapFrame = null;
            window.setTimeout("RetryInit();", 500);
        }
</script>

<!-- HTML part -->
<html>
<body>
    <iframe id="viewerFrame" frameborder="yes" width="100%" height="60%" 
src=" 
src="../mapviewernet/dwfviewer.aspx?SESSION=<%=sessionId%>&WEBLAYOUT=<%=webLayout%>"" 
onload="RetryInit()"></iframe>
</body>
</html>


Regards. Kenneth, GEOGRAF A/S



Nick Aizen skrev:
>
> Can anyone help me with this process, I'm new to both web development 
> and MapGuide API development, so please excuse me if I don't ask my 
> question the correct way but basically....
>
> I want to be able to load a weblayout (created in MG Studio),  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.
>
>  
>
>  I would appreciate it if someone can provide a code snippet. I'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's provided my Autodesk are 
> there any helpful resources for developers?
>
>  
>
> Here's the code when the page loads that loads a weblayout:
>
>   MgUserInformation userInfo = new MgUserInformation("Administrator", 
> "admin");
>
>     MgSite site = new MgSite();
>
>     site.Open(userInfo);
>
>  
>
>     String sessionId = site.CreateSession();
>
>     String webLayout = "Library://DevTV/HelloWorld.WebLayout";
>
>  
>
>  
>
> 'Need help with API to query and zoom'
>
>  
>
>  
>
>  
>
> Then the layout is passed to the viewer.
>
>  
>
> <frameset rows="0,*" border="0" framespacing="0">
>
>   <frame />
>
>   <frame src="/mapguide2008/mapviewernet/ajaxviewer.aspx?SESSION=<%= 
> sessionId %>&WEBLAYOUT=<%= webLayout %>" name="ViewerFrame" />
>
> </frameset>
>
>  
>
>  
>
> Many Thanks,
>
>  
>
> *Nick Aizen*
>
>  
>
>  
>
>  
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20080502/ac919fad/attachment.html


More information about the mapguide-users mailing list