Help with URI

6 posts, 1 answers
  1. Steve
    Steve avatar
    4 posts
    Member since:
    May 2011

    Posted 28 Sep 2011 Link to this post

    Hello everyone,

    Quite new to all of this, so I'm hoping someone can nudge me in the right direction.  I'm trying to load a KML file, but I can't seem to get my head around the URI part.  Can someone provide me with an idiot-proof example?  For instance, if I have a project called "Map_Test" and within that project I have a folder called "Recources" and within that folder I have a file called "doc.kml", what would be the uri?

    This is what I tried and I get the message that "Cannot locate resource 'Map_Test;resources/doc.kml'.

    Any help is greatly appreciated.  Here is my code:

    Private Sub LoadKMLData()
        Dim streamResource As StreamResourceInfo = Application.GetResourceStream(New Uri("pack://application:,,,/Map_Test;Resources/doc.kml", UriKind.RelativeOrAbsolute))
        Dim elements As List(Of FrameworkElement) = KmlReader.Read(streamResource.Stream)
        For Each element As FrameworkElement In elements
            Me.informationLayer.Items.Add(element)
        Next element
    End Sub





    Also tried this with no luck either.  Gives me a "Cannot locate resouce 'doc.kml':





    Dim
    streamResource As StreamResourceInfo = Application.GetResourceStream(New Uri("/Map_Test;component/Resources/doc.kml", UriKind.RelativeOrAbsolute))
    ' Dim streamResource As StreamResourceInfo = Application.GetResourceStream(New Uri("doc.kml", UriKind.RelativeOrAbsolute))
    Dim elements As List(Of FrameworkElement) = KmlReader.Read(streamResource.Stream)
    For Each element As FrameworkElement In elements
        Me.informationLayer.Items.Add(element)
    Next element


  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 29 Sep 2011 Link to this post

    Hello Steve,

    First of all, I would recommend you to take a look into this article in MSDN:

    http://msdn.microsoft.com/en-US/library/aa970069.aspx

    The URI for the resource file located in the Resources folder of the Map_Test project should look like the following:

    "pack://application:,,,/Map_Test;component/Resources/doc.kml"
    or
    "/Map_Test;component/Resources/doc.kml"

    Also you've forgot the 'component' world in the URI.

    Best wishes,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Steve
    Steve avatar
    4 posts
    Member since:
    May 2011

    Posted 29 Sep 2011 Link to this post

    Hello Andrey,

    Still no luck!  Here's my xaml:

    <Window x:Class="MainWindow"
        Title="MainWindow" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
        <Grid>
            <telerik:RadMap Height="208" HorizontalAlignment="Left" Margin="38,20,0,0" Name="RadMap1" VerticalAlignment="Top" Width="316">
                <telerik:InformationLayer x:Name="informationLayer" />
            </telerik:RadMap>
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="426,249,0,0" Name="Button1" VerticalAlignment="Top" Width="75" />
        </Grid>
    </Window>

    Here is my vb:
    Imports System.Windows.Resources
    Imports Telerik.Windows.Controls.Map
      
    Class MainWindow
      
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
            Me.RadMap1.Provider = New BingMapProvider(MapMode.Road, True, "AlZ0xl0gPk3tLAXRH7oaYQk2buRQ62MKNPGpZG0YoJTc5TRRk0IkluRm_3zSqK7f")
            LoadKMLData()
        End Sub
        Private Sub LoadKMLData()
            Dim streamResource As StreamResourceInfo = Application.GetResourceStream(New Uri("/Map_Test;component/Resources/doc.kml", UriKind.RelativeOrAbsolute))
            Dim elements As List(Of FrameworkElement) = KmlReader.Read(streamResource.Stream)
            For Each element As FrameworkElement In elements
                Me.informationLayer.Items.Add(element)
            Next element
        End Sub

    Two issues:

    1) No bing map shows up.  I've confirmed the key is correct
    2) Still getting the Cannot locate resource 'resouces/doc.kml' message.  I've confirmed that the kml file is in the following path:

     

    C:\...\Documents\visual studio 2010\Projects\Map_Test\Map_Test\Resources

    I've followed the instructions here: http://www.telerik.com/help/silverlight/radmap-features-kml-data-import.html to see if the Reading KML files with RadMaps works and I'm not getting an option for Reader.Source.  I just get SetCurrentValue and .SetValue. 

    I'm sure it's user error, but following the instructions in the help section and what you've posted below I still can't seem to sort it out. 

    Any ideas? 
  5. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 30 Sep 2011 Link to this post

    Hello Steve,

    First of all you should be sure that your kml-file is included to your project as Resource:
    1. Select doc.kml in the solution explorer.
    2. Go to the "Properties" window.
    3. Check that "Build Action" set to "Resource".

    If the problem still persists, then please send us your runnable solution for detail analysis.

    All the best,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Steve
    Steve avatar
    4 posts
    Member since:
    May 2011

    Posted 30 Sep 2011 Link to this post

    Thanks Andrey, that took care of issue #2, where I was getting the resouce not found.  I'm not getting an image to come up though.  I think there's some communcation issue between me and bing maps as no map is displayed (and there is no error either).

    Using Open Street Map works, but trying to set the mapmode results in an error (Too many arguements to 'Public Sub New()').  Here's the code I'm using:

            Dim provider As New OpenStreetMapProvider(MapMode.Road, True)
            Me.RadMap1.Provider = provider
  7. Steve
    Steve avatar
    4 posts
    Member since:
    May 2011

    Posted 30 Sep 2011 Link to this post

    Maybe OpenStreetMaps doesn't have a .road option.  Eitherway, I think the matter is closed.  Thanks for all your help!
Back to Top
UI for WPF is Visual Studio 2017 Ready