[mapguide-users] Select specific layer and feature by passing value to flexible layout (AIMS2014)

RenoSun renolionheart at gmail.com
Sat Jun 8 16:44:29 PDT 2013


Hello Guys,

Finally, I found how to solved my pre-selected problem. 

The code will be following....

First, my GeoRest page will have a link like this
Property.aspx?MBR={{Property_Geometry_BBOX}}&Centroid={{Property_Geometry_Centroid_X}},{{Property_Geometry_Centroid_Y}}

Second, when user link to my Property.aspx page of my Autodesk
Infrastructure Map Server 2014 application will include following code:

   string extent =
"-13860793.173271,6329131.950798,-13845619.906785,6337107.916411";
    string centroid = "";

     if (Request.QueryString["MBR"] != "" && Request.QueryString["MBR"] !=
null)
        {

            string[] MBR = Request.QueryString["MBR"].Split(',');

            double lowx = double.Parse(MBR[0]);
            double lowy = double.Parse(MBR[1]);
            double uppx = double.Parse(MBR[2]);
            double uppy = double.Parse(MBR[3]);



            // Coordinates System Transformation
            MgCoordinateSystemFactory coordSysFactory = new
MgCoordinateSystemFactory();
            MgCoordinateSystemCatalog csCatalog =
coordSysFactory.GetCatalog();
            MgCoordinateSystemDictionary csDict =
csCatalog.GetCoordinateSystemDictionary();
            MgCoordinateSystemDatumDictionary datumDict =
csCatalog.GetDatumDictionary();
            MgCoordinateSystemEllipsoidDictionary ellipsoidDict =
csCatalog.GetEllipsoidDictionary();
            MgCoordinateSystemFormatConverter formatConverter =
csCatalog.GetFormatConverter();
            MgCoordinateSystemMathComparator mathComparator =
csCatalog.GetMathComparator();
            MgCoordinateSystemProjectionInformation projectionInformation =
csCatalog.GetProjectionInformation();
            MgCoordinateSystemUnitInformation unitInformation =
csCatalog.GetUnitInformation();

            // geographic to projected
            MgCoordinateSystem LL84 = csDict.GetCoordinateSystem("LL84");
            MgCoordinateSystem WGS84PM =
csDict.GetCoordinateSystem("WGS84.PseudoMercator");
            MgCoordinateSystemTransform LL84ToWGS84PM =
coordSysFactory.GetTransform(LL84, WGS84PM);
            MgCoordinate LL84ToWGS84PMCoordLowXY =
LL84ToWGS84PM.Transform(lowx, lowy);
            MgCoordinate LL84ToWGS84PMCoordUpXY =
LL84ToWGS84PM.Transform(uppx, uppy);

            string WGSPMlowx = LL84ToWGS84PMCoordLowXY.GetX().ToString(); 
            string WGSPMlowy = LL84ToWGS84PMCoordLowXY.GetY().ToString(); 
            string WGSPMupx = LL84ToWGS84PMCoordUpXY.GetX().ToString(); 
            string WGSPMupy = LL84ToWGS84PMCoordUpXY.GetY().ToString(); 
            extent = WGSPMlowx+','+WGSPMlowy+','+WGSPMupx+','+WGSPMupy;
    }

    if (Request.QueryString["Centroid"] != "" &&
Request.QueryString["Centroid"] != null)
        {

            string[] Centroid = Request.QueryString["Centroid"].Split(',');

            double cx = double.Parse(Centroid[0]);
            double cy = double.Parse(Centroid[1]);



            // Coordinates System Transformation
            MgCoordinateSystemFactory coordSysFactory = new
MgCoordinateSystemFactory();
            MgCoordinateSystemCatalog csCatalog =
coordSysFactory.GetCatalog();
            MgCoordinateSystemDictionary csDict =
csCatalog.GetCoordinateSystemDictionary();
            MgCoordinateSystemDatumDictionary datumDict =
csCatalog.GetDatumDictionary();
            MgCoordinateSystemEllipsoidDictionary ellipsoidDict =
csCatalog.GetEllipsoidDictionary();
            MgCoordinateSystemFormatConverter formatConverter =
csCatalog.GetFormatConverter();
            MgCoordinateSystemMathComparator mathComparator =
csCatalog.GetMathComparator();
            MgCoordinateSystemProjectionInformation projectionInformation =
csCatalog.GetProjectionInformation();
            MgCoordinateSystemUnitInformation unitInformation =
csCatalog.GetUnitInformation();

            // geographic to projected
            MgCoordinateSystem LL84 = csDict.GetCoordinateSystem("LL84");
            MgCoordinateSystem WGS84PM =
csDict.GetCoordinateSystem("WGS84.PseudoMercator");
            MgCoordinateSystemTransform LL84ToWGS84PM =
coordSysFactory.GetTransform(LL84, WGS84PM);
            MgCoordinate LL84ToWGS84PMCoordcXY = LL84ToWGS84PM.Transform(cx,
cy);

            string WGSPMcx = LL84ToWGS84PMCoordcXY.GetX().ToString(); 
            string WGSPMcy = LL84ToWGS84PMCoordcXY.GetY().ToString(); 
            centroid = WGSPMcx+','+WGSPMcy;
    }
%>


<frame
src="../mapserver2014/fusion/templates/mapguide/turquoiseyellow/index.html?ApplicationDefinition=Library%3a%2f%2fQualicumBeach%2fFlexibleLayouts%2fProperty.ApplicationDefinition&SESSION=<%=
mysessionid %>&extent=<%= extent  %>&centroid=<%= centroid  %>"
id="ViewerFrame" name="ViewerFrame">


Third, my fusion index.html will be modified as following:

        var fusionInitialized = function () {
            $('AppContainer').resize({ forceResize: true });
            var mapWidget = Fusion.getMapById('Map');
            mapWidget.registerForEvent(Fusion.Event.MAP_LOADED,
initPanelHandler);
        }
       
        var initPanelHandler = function () {
            if (isTaskPaneRegistered) return;

            var a = window.location.toString();

            if(a.split("centroid=") == true){
            var centroid = a.split("centroid=");
            Fusion.registerForEvent(Fusion.Event.TASK_PANE_LOADED,
showSelectionPanel);
            if (centroid[1] != '') {

                centroid = centroid[1].split(",");
                var cx = centroid[0];
                var cy = centroid[1];
                //alert(cx+','+cy);
                var lowx = (cx - 1);
                var lowy = (cy - 1);
                var uppx = (cx + 1);
                var uppy = (cy + 1);

                //alert(lowx + ',' + lowy+':'+uppx+','+uppy);

                var mapWidget = Fusion.getMapById('Map');
                var sessionid = getMapGuideSessionID(mapWidget);
                var mapname = getMapGuideMapName(mapWidget);
                var options = {};
                options.version = '1.0.0';
                options.locale = 'en';
                options.clientagent = 'Fusion Viewer';
                options.operation = 'QUERYMAPFEATURES';
                options.format = 'application/json';
                options.session = sessionid;
                options.mapname = mapname;
                options.maxFeatures = 1;
                options.persist = 1;
                options.selectionVariant = 'INTERSECTS';
                //parent.parent.SetSelectionXML(selectionXml);
                mapWidget.query(options);
             }   
            }
        }

    


Hope someone will be benefited from this post 

Thank you for everyone involving this post !!!!






--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Select-specific-layer-and-feature-by-passing-value-to-flexible-layout-AIMS2014-tp5055669p5058886.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list