This is a migrated thread and some comments may be shown as answers.

Shapefile shows in preview, not in debug

4 Answers 90 Views
Map
This is a migrated thread and some comments may be shown as answers.
Wyatt
Top achievements
Rank 1
Wyatt asked on 07 Jul 2014, 01:08 PM
Doing a very simple shapefile based map.  I can see the map in preview, but not when I debug.  shapefiles are in a folder called Shapes just off the project root.

  <telerik:RadMap HorizontalAlignment="Left" Center="40,-74" VerticalAlignment="Top" Height="500" Width="600">
            <telerik:RadMap.Provider>
                <telerik:EmptyProvider />
            </telerik:RadMap.Provider>
            <telerik:InformationLayer x:Name="informationLayer" >
                <telerik:InformationLayer.Reader>
                    <telerik:MapShapeReader x:Name="xShapReader"
                                            Source="pack://siteoforigin:,,,/Shapes/cb_2013_us_state_500k.shp" 
                                            DataSource="pack://siteoforigin:,,,/Shapes/cb_2013_us_state_500k.dbf" 
                                            PreviewReadCompleted="MapShapeReader_PreviewReadCompleted" />
                </telerik:InformationLayer.Reader>


                <telerik:InformationLayer.ShapeFill>
                    <telerik:MapShapeFill Fill="#FFF0D9" Stroke="#B1946D" StrokeThickness="1" />
                </telerik:InformationLayer.ShapeFill>
            </telerik:InformationLayer>
        </telerik:RadMap>

4 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 08 Jul 2014, 08:12 AM
Hello Wyatt,

It is hard to say about particular causes of this problem without your solution, but using just a code snippet you sent. But it looks the properties of shp and dbf files in your project are incorrect. You should be sure that your shape-file is copied to the output directory:
1. Select the cb_2013_us_state_500k.shp and dbf in the solution explorer.
2. Go to the "Properties" window.
3. Check that "Build Action" is set to "None".
4. Check that "Copy to Output Directory" is set to "Copy always" or to "Copy if newer".

Also you can check an error which can occur during loading of shape-file. You can check the PreviewReadShapesCompletedEventArgs.Error property in your PreviewReadCompleted event handler. It returns the exception when an error occurs.
The sample code is below.

private void MapShapeReader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
{
    if (eventArgs.Error != null)
    {
        MessageBox.Show(eventArgs.Error.Message);
    }
    else
    {
        // process items
        // eventArgs.Items contains the list of objects which are created by MapShapeReader
    }
}
I hope this information will be helpful.

Regards,
Andrey Murzov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Wyatt
Top achievements
Rank 1
answered on 08 Jul 2014, 01:22 PM
Thank you for the reply.  There really isn't anything else to the code.
I made the changes you suggested and it  does return the following error, but it's pretty generic "An exception occured during a WebClient request".

Here is all the code. nothing in the .cs file except the exception cache you suggested.


<Window x:Class="TelerikWpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Title="MainWindow" Height="584" Width="810">
<Grid>
<telerik:RadMap x:Name="xRadMap"
HorizontalAlignment="Left"
Center="39.5,-98.35"
ZoomLevel="3"
VerticalAlignment="Top"
Height="500" Width="600"
RenderTransformOrigin="0.445,0.492"
MouseClickMode="ZoomPointToCenter"
>
<telerik:RadMap.Provider>
<!--<telerik:ArcGisMapProvider Mode="Street" />-->
<telerik:EmptyProvider></telerik:EmptyProvider>
</telerik:RadMap.Provider>
<telerik:InformationLayer x:Name="xInfo" >
<telerik:InformationLayer.Reader>
<telerik:MapShapeReader x:Name="xShapeReader"
Source="pack://siteoforigin:,,,/Shapes/cb_2013_us_state_500k.shp"
DataSource="pack://siteoforigin:,,,/Shapes/cb_2013_us_state_500k.dbf"
PreviewReadCompleted="MapShapeReader_PreviewReadCompleted" />
</telerik:InformationLayer.Reader>
 
<telerik:MapPinPoint telerik:MapLayer.Location="42.2311,-87.9692" Text="1" ImageScale=".08" ImageSource="/Images/img1.jpg" ></telerik:MapPinPoint>
<telerik:MapPinPoint telerik:MapLayer.Location="43.8833,-79.2500" Text="2" ImageScale=".08" ImageSource="/Images/img1.jpg" ></telerik:MapPinPoint>
<telerik:MapPinPoint telerik:MapLayer.Location="19.531120,-99.2077607" Text="3" ImageScale=".08" ImageSource="/Images/MITSUBISHI.jpg" ></telerik:MapPinPoint>
<telerik:MapPinPoint telerik:MapLayer.Location="34.0031,-84.1456" Text="4" ImageScale=".08" ImageSource="/Images/img1.jpg" ></telerik:MapPinPoint>
<telerik:MapPinPoint telerik:MapLayer.Location="33.8183,-118.0392" Text="5" ImageScale=".08" ImageSource="/Images/img1.jpg" ></telerik:MapPinPoint>
<telerik:MapPinPoint telerik:MapLayer.Location="43.7000,-79.4000" Text="6" ImageScale=".08" ImageSource="/Images/img1.jpg" ></telerik:MapPinPoint>

</telerik:InformationLayer>
</telerik:RadMap>
<Button Content="Home" HorizontalAlignment="Left" Height="39" Margin="625,10,0,0" VerticalAlignment="Top" Width="98" Click="Button_Click"/>
<ComboBox x:Name="Cities" HorizontalAlignment="Left" Margin="605,75,0,0" VerticalAlignment="Top" Width="120" SelectionChanged="Cities_SelectionChanged" >
<ListBoxItem Content="1l" Uid="1"/>
<ListBoxItem Content="2" Uid="2"/>
<ListBoxItem Content="3" Uid="3"/>
<ListBoxItem Content="4" Uid="4"/>
<ListBoxItem Content="5" Uid="5"/>
<ListBoxItem Content="6" Uid="6"/>
</ComboBox>
</Grid>
</Window>
0
Wyatt
Top achievements
Rank 1
answered on 08 Jul 2014, 01:38 PM
the inner exception is "The URI prefix is not recognized."
0
Wyatt
Top achievements
Rank 1
answered on 08 Jul 2014, 01:59 PM
resolved now.  I was using the properties window for the information layer to select the datasource and source. looks like it doesn't put in the right information for it to work.
Tags
Map
Asked by
Wyatt
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Wyatt
Top achievements
Rank 1
Share this question
or