Select to view content in your preferred language

Loaded Service urls dynamically?

589
1
04-19-2013 07:08 AM
matthewbennion
New Contributor
Hi,
I'm guessing this isn't possible for all layers but, I have a live and dev instance of a system and the services in each to point different urls.

    Private Sub Map1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)

        Dim strAddress As String = Application.Current.Host.Source.ToString
        Dim strServiceAddressOrganisations As Strin

        'refresh of cluster boundaries dynamic map service layer endpoint
        dynamicMapServiceLayerClusterBoundaries = Map1.Layers("Cluster Boundaries")
        dynamicMapServiceLayerClusterBoundaries.DisableClientCaching = True
        dynamicMapServiceLayerClusterBoundaries.Url = servicesAddress & "/Clusters/MapServer/"

        'refresh of organisations feature layer endpoint
        featureLayerOrganisations = Map1.Layers("Organisations")
        featureLayerOrganisations.DisableClientCaching = True
        featureLayerOrganisations.Url = strServiceAddressOrganisations

        dt.Start()

    End Sub


The code doesn't work and complains no URLS have been set, I'm guessing this is because in the XAML no urls are set?
0 Kudos
1 Reply
DaveTimmins
Deactivated User
The code below looks like it has some errors, the third line of code is missing a g on the end and the strServiceAddressOrganisations variable is never set. In terms of setting the url's dynamically you can do it, there are a number of options. You can set values in your web.config and pass them through to the Silverlight plugin, or have them in a database and provide access via a service or the like or you can load the xaml dynamically which contains the layer markup. A couple of blogs that discuss some of these techniques are

http://davetimmins.wordpress.com/2011/07/22/dynamically-loading-layers-at-runtime-with-silverlight/

http://www.gal-systems.com/2011/08/passing-parameters-to-silverlight.html

Cheers,
0 Kudos