[mapguide-users] Re: ZoomToView in Javascript

djonio DJonio at miami-airport.com
Wed Feb 2 13:36:19 EST 2011


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-tp5985850p5985997.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list