[mapguide-users] polygon zoom problem

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Mon May 25 03:23:33 EDT 2009


Do you get any javascript errors?
Are your x,y and scale values correct in the javascript?

Regards, Kenneth Skovhede, GEOGRAF A/S



padmini godavarthi skrev:
>
>  Hi,
> iam using mapguide opensource 2.0 (with .net 2.0 +IIS 5.1) on win xp 
>
> i have a problem with zom toview function??????????????????
>
>  Try
>
>
>             If Not Session("id1") Is Nothing Then
>
>
>                 Dim mapCenterX As Double
>                 Dim mapCenterY As Double
>
>                 Dim serverVars As NameValueCollection =
> Request.ServerVariables
>                 Dim strServerVars As String = ""
>                 Dim str1 As String
>                 For Each str1 In serverVars.AllKeys
>                     strServerVars += "<br>" & str1
>                 Next
>                 Dim platform As String = serverVars("SERVER_SOFTWARE")
>                 Dim queryStr As String = serverVars("QUERY_STRING")
>                 Dim queryStr1 As String = serverVars("Form")
>                 Dim requestParams As NameValueCollection =
> IIf(Request.HttpMethod = "POST", Request.Form, Request.QueryString)
>                 Dim sessionId As String = Request.QueryString("SESSION")
>                 Dim realPath As String =
> Request.ServerVariables("APPL_PHYSICAL_PATH")
>                 Dim configPath As String = realPath + "webconfig.ini"
>                 MapGuideApi.MgInitializeWebTier(configPath)
>                 Dim userInfo As MgUserInformation = New
> MgUserInformation(sessionId)
>                 Dim siteConnection As MgSiteConnection = New
> MgSiteConnection
>                 siteConnection.Open(userInfo)
>                 Dim resService As MgResourceService =
> siteConnection.CreateService(MgServiceType.ResourceService)
>                 Dim featureService As MgFeatureService =
> siteConnection.CreateService(MgServiceType.FeatureService)
>                 Dim fetresource As MgResourceIdentifier = New
> MgResourceIdentifier("Library://propertytax/resource.FeatureSource")
>                 Dim nameQuery As MgFeatureQueryOptions = New
> MgFeatureQueryOptions()
>                 Dim val As String = "PARCEL_ID"
>                 nameQuery.AddFeatureProperty(val)
>                 Dim queryval As String = Session("id1")
>                 Dim totquery As String = val & "=" & "'" & queryval & "'"
>                 nameQuery.SetFilter(totquery)
>                 Dim tabname As String = "PROPERTY LAYER"
>                 Dim map As MgMap = New MgMap()
>                 map.Open(resService, "oramap")
>                 Dim layer As MgLayer = map.GetLayers().GetItem("PROPERTY
> LAYER")
>                 Dim geometryReaderWriter As MgAgfReaderWriter = New
> MgAgfReaderWriter()
>                 Dim featureReader As MgFeatureReader =
> featureService.SelectFeatures(fetresource, layer.GetFeatureClassName(),
> nameQuery)
>                 Dim geometryFactory As MgGeometryFactory = New
> MgGeometryFactory()
>                 While featureReader.ReadNext()
>                    Dim byteReader As MgByteReader =
> featureReader.GetGeometry("GEOMETRY")
>                    Dim geometry As MgGeometry =
> geometryReaderWriter.Read(byteReader)
>                    Dim centroid As MgPoint = geometry.GetCentroid()
>                   mapCenterX = centroid.GetCoordinate().GetX()
>                    mapCenterY = centroid.GetCoordinate().GetY()
>          Page.ClientScript.RegisterStartupScript(Page.GetType(), "test",
> "highlight(" & mapCenterX & "," & mapCenterY & ");", True)
>                 'End While
>                 featureReader.Close()
>                 Dim resService1 As MgResourceService =
> CType(siteConnection.CreateService(MgServiceType.ResourceService),
> MgResourceService)
>                 Dim featureService1 As MgFeatureService =
> CType(siteConnection.CreateService(MgServiceType.FeatureService),
> MgFeatureService)
>                 Dim fetresource1 As MgResourceIdentifier = New
> MgResourceIdentifier("Library://propertytax/resource.FeatureSource")
>                 Dim nameQuery1 As MgFeatureQueryOptions = New
> MgFeatureQueryOptions()
>                 Dim val1 As String = "PARCEL_ID"
>                 nameQuery1.AddFeatureProperty(val1)
>                 Dim queryval1 As String = Session("id1")
>                 Dim totquery1 As String = val1 + "=" + "'" + queryval1 + "'"
>                 nameQuery1.SetFilter(totquery1)
>                 Dim layer1 As MgLayer = map.GetLayers().GetItem("PROPERTY
> LAYER")
>                 Dim featureReader1 As MgFeatureReader =
> featureService1.SelectFeatures(fetresource1, layer1.GetFeatureClassName(),
> nameQuery1)
>                 Dim selection As MgSelection = New MgSelection(map)
>                 selection.AddFeatures(layer1, featureReader1, 0)
>                 Dim selectXML As String = selection.ToXml()
>                 selection.Save(resService1, "oramap")
>                 Page.ClientScript.RegisterStartupScript(Page.GetType(),
> "test", "select('" & selectXML & "')", True)
>                 featureReader1.Close()
>
>             End If
>                   
>          
>         Catch ex As Exception
>             'MsgBox(ex.Message)
>         End Try
>
> -----------------------------------------------------------------------
>
> and my java script functions are
>
>
> function select(val) {
>      
>          var selectionXML = val;
>           parent.parent.SetSelectionXML(selectionXML); 
>          //    parent.parent.mapFrame.ZoomToView(x,y,2000,true); 
>         
>        parent.parent.refresh;
>          alert("Selected");
>          
>         }
>         function highlight(x,y) 
>         {
>            //  alert("2nd");
>              
>            var xval = x;
>            var yval = y;
>        
>           parent.parent.mapFrame.ZoomToView(xval,yval,1000,true); 
>          
>         }
>
> i wrote all this code in taskpane page loading even
> but i didnt get the exact zoom level of that parcel it remains same as the
> initial view
>
> can any one plz tell me the solution????????????????????????????
>
>
> Regards,
> padmini.
>
>
>   


More information about the mapguide-users mailing list