Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
335
Cambiar la visualizacíon del mapa entre dos valores
posted

hello

I have a map that reads the information from the SQL Server.

Get from the database to represent 2 values.

Clik Using a listbox, I want to be shown on the map with the value 1 or the value 2. The ultimate goal is to display the same as when you load the map the first time (by default with the value 1)

Like the example http://labs.infragistics.com/silverlightdv/2010.3/ # / Samples / Map / BindingWCFDataFilteringSource

If I do as an example, does not load any data.

If I do it with the following code, the map changes but does not display any data:

 Private Sub OnDataChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim ItemSeleccionado As ListBoxItem = sender.SelectedItem
        Dim TextoSeleccionado As String = ItemSeleccionado.Tag.ToString
        Dim converter As New DataMapping.Converter()

        Select Case TextoSeleccionado
            Case "Facturacion"

                Dim sqlReader As SqlShapeReader = TryCast(xamMap.Layers("CapaAutonimias").Reader, SqlShapeReader)
                sqlReader.DataMapping = TryCast(converter.ConvertFromString("Data=geom;Name=NAME_1; Caption=NAME_1;Value=ValorF"), DataMapping)
                xamMap.Layers("CapaAutonimias").Reader = sqlReader
                xamMap.Layers("CapaAutonimias").ToolTip = "{}{Name}: Facturación {Value:n0} €"

            Case "Ventas"
                Dim sqlReader As SqlShapeReader = TryCast(xamMap.Layers("CapaAutonimias").Reader, SqlShapeReader)
                sqlReader.DataMapping = TryCast(converter.ConvertFromString("Data=geom;Name=NAME_1; Caption=NAME_1;Value=ValorV"), DataMapping)
                xamMap.Layers("CapaAutonimias").Reader = sqlReader
                xamMap.Layers("CapaAutonimias").ToolTip = "{}{Name}: Ventas {Value:n0} Uds"
        End Select
        xamMap.Layers("CapaAutonimias").DataBind()

Thanks

Parents
  • 3255
    Suggested Answer
    posted

    Hi jcsanchezr,

    MapLayer Reader's DataMapping is used in the process of mapping your objects to MapElements and changing if after that will not have any effect. As a workaround the following:

    1. Set Reader's DataMapping in XAML or code behind:

     DataMapping="Value=ValorF; Value2=ValorV"

     2. In OnDataChanged iterate all map elements and set the new value

    foreach (var element in xamMap.Layers[0].Elements)
    {
     //Case "Ventas"
     element.Value = Convert.ToDouble(element.GetProperty("Value2"));
     
     or
     
     //Case "Facturacion"
     element.Value = Convert.ToDouble(element.GetProperty("Value"));

    Regards,

    Ivan Kotev

Reply Children