[mapguide-users] prob with GetSelectionXml()

Chris Claydon chris.claydon at autodesk.com
Tue May 26 11:19:16 EDT 2009


I'm not too familiar with VB, but don't you need to call Layers.GetCount() (i.e. using brackets (), since it's a method)?

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of wakrimsaloua.wakrim at gmail.com
Sent: Tuesday, May 26, 2009 9:14 AM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] prob with GetSelectionXml()

hi all! i've prob with use the xml selection wich i get after user clic on polygone, this is javascript function i use to get selection:(i write it in textfiel and read it by Request.Form:

  function test()
    {
   
 k= document.formulaire.classe.value=carte.GetMapFrame().GetSelectionXML(); 
    

    }

for get this selection i use this code

 selectionXml = getValue("classe")


  Private Function getValue(ByVal champ As String) As String
        ' récupère la valeur du champ [champ] de la requête postée
        ' qq chose ?
        If Request.Form(champ) Is Nothing Then Return ""
        ' on récupère la ou les valeurs du champ
        Dim valeurs() As String = Request.Form.GetValues(champ)
        Dim valeur As String = ""
        Dim i As Integer
        For i = 0 To valeurs.Length - 1
            valeur += valeurs(i)
        Next
        valeur = Server.UrlDecode(valeur)

        Return valeur
    End Function

after user clic on polygone and get xml selection , i use this code for filter and identify polygone ID:

 Public Sub getselectionpartiel(ByVal map As MgMap, ByVal resourceService As MgResourceService, ByVal XmlSel As String)
        
    
        Dim k = 0
           If ((XmlSel <> Nothing) And (XmlSel <> "")) Then

                    
            Dim selection As New MgSelection(map, XmlSel)
            Dim Layers As MgReadOnlyLayerCollection = selection.GetLayers()

            
            If Not Layers.GetCount = 1 Then
                Response.Write("More than one object was selected")

                Exit Sub

            End If


         
            
          

            Response.Write("calques selectionnés")
    

     
        End If

    End Sub
 and i call this function like that:
    getselectionpartiel(map, resourceSrvc, selectionXml)

it gives me this error:

"La référence d'objet n'est pas définie à une instance d'un objet." in the line:
(the object reference is not associated to the object instance)
    If Not Layers.GetCount = 1 Then

i think that Layers is empty but when i display "selectionXml" by using:

Response.Write(selectionXml) it gives me the correct selection!!!
if some one has some idea please tell it me, thanks a lot on advance


_______________________________________________
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