[mapguide-users] prob with GetSelectionXml()

wakrimsaloua.wakrim at gmail.com wakrimsaloua.wakrim at gmail.com
Tue May 26 11:13:32 EDT 2009


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




More information about the mapguide-users mailing list