[mapguide-users] Re: ZoomToView in Javascript

Carrillo, John JBCarrillo at rcflood.org
Wed Feb 2 14:51:17 EST 2011


Thanks Dennis....I got it working.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of djonio
Sent: Wednesday, February 02, 2011 10:36 AM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] Re: ZoomToView in Javascript


Since you have MG within an Iframe you have to get a reference to the
document within the iframe.
I am using jQuery here and you, of course, do not need to. Within your
javascript something like:
        var mainFrame;
        var mapFrame;
        var taskFrame;
        var scriptFrame;
        var formFrame;
        var legendControl;
        var propertyControl;
       
function SetLocalVars() {
            try {
                MainApp_DOMframe = jQuery('iframe[id="MAPIAM"]').get(0);
                mainFrame = (MainApp_DOMframe.contentWindow ||
MainApp_DOMframe.contentDocument);
                mapFrame = mainFrame.GetMapFrame();
                taskFrame = mainFrame.GetTaskFrame();
                scriptFrame = mainFrame.GetScriptFrame();
                formFrame = mainFrame.GetFormFrame();
                legendControl = mapFrame.GetLegendCtrl();
                propertyControl = mapFrame.GetPropertyCtrl();
            } catch (Exception) { }
        }

.... and in this case the iframe was loaded as ....
HtmlControl frame1 = new
System.Web.UI.HtmlControls.HtmlGenericControl("iframe");
            frame1.Attributes["src"] = "http://"
                + dnsname
                + "/mapguide/mapviewerajax/ajaxviewer.aspx?SESSION="
                + mgsessionid 
                + "&WEBLAYOUT="
                + weblayout;
            frame1.Attributes["frameborder"] = "0";
            frame1.Attributes["scrolling"] = "auto";
            frame1.Attributes["width"] = "100%";
            frame1.Attributes["height"] = "565px";
            frame1.Attributes["allowTransparency"] = "true";
            frame1.Attributes["id"] = "MAPIAM";
            frame1.Attributes["name"] = "MAPIAM";
            MapPlaceHolder.Controls.Add(frame1);


Please, remember that this will not work until the "map" gets loaded.
There
are a couple examples as to how to accomplish this on the MG site.
Hope this helps...
r, dennis

-- 
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/ZoomToView-in-Javascript-tp598585
0p5985997.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users


More information about the mapguide-users mailing list