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

Unable to see map

8 Answers 213 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 02 Feb 2011, 01:16 AM
Hello-

I am trying to display the RadMap, but when executed, the map isnt being displayed, just the background.  It's like the shapefile & dbf arent being loaded properly.  I've tried setting the Source and DataSource a few different ways and none seem to work.  I have the shp & dbf files located in a folder called Resources at the root of my project.  Below is a section of my xaml.  Any advice?

Thanks!
Jeremy

<telerik:RadMap x:Name="RadMap1"
                    Background="#D9E1FF"
                    BorderBrush="Black"
                    BorderThickness="0"
                    UseDefaultLayout="False"
                    MouseClickMode="None"
                    MouseDoubleClickMode="None">
            <telerik:RadMap.Provider>
                <telerik:EmptyProvider MinZoomLevel="1" MaxZoomLevel="8" />
            </telerik:RadMap.Provider>
            <telerik:InformationLayer x:Name="WorldLayer">
                <telerik:InformationLayer.Reader>
                    <telerik:MapShapeReader Source="/DynamicsMap;component/Resources/world.shp"
                                            DataSource="/DynamicsMap;component/Resources/world.dbf"
                                            ToolTipFormat="CNTRY_NAME"/>
                </telerik:InformationLayer.Reader >
                <telerik:InformationLayer.ShapeFill>
                    <telerik:MapShapeFill Fill="#FFF0D9" Stroke="#B1946D" StrokeThickness="1" />
                </telerik:InformationLayer.ShapeFill>
                <telerik:InformationLayer.HighlightFill>
                    <telerik:MapShapeFill Fill="#FFEEA6" Stroke="#B1946D" StrokeThickness="1" />
                </telerik:InformationLayer.HighlightFill>
            </telerik:InformationLayer>
        </telerik:RadMap>

8 Answers, 1 is accepted

Sort by
0
Lyndsay
Top achievements
Rank 1
answered on 03 Feb 2011, 08:58 PM
I'm having a similar issue.  When I run my project I get the following error:

System.FormatException
Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Telerik.Windows.Controls.Map.DbfReader.GetNextRecord() in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\ShapeFile\DbfReader\DbfReader.cs:line 123

<telerik:RadMap Height="377" HorizontalAlignment="Left" Margin="12,25,0,0" Name="radMap1" VerticalAlignment="Top" Width="441">
    <telerik:RadMap.Provider>
        <telerik:EmptyProvider MinZoomLevel="4" MaxZoomLevel="5" />
    </telerik:RadMap.Provider>
    <telerik:InformationLayer x:Name="InformationLayer">
        <telerik:InformationLayer.Reader>
            <telerik:MapShapeReader SourceType="ShapeFile" Source="/TexasMap;component/ShapeFiles/tx.shp" DataSource="/TexasMap;component/ShapeFiles/tx.dbf"/>
        </telerik:InformationLayer.Reader>
        <telerik:InformationLayer.ShapeFill>
            <telerik:MapShapeFill Fill="#FFF7DE" Stroke="#5A636B" StrokeThickness="1" />
        </telerik:InformationLayer.ShapeFill>
        <telerik:InformationLayer.HighlightFill>
            <telerik:MapShapeFill Fill="#F7E7BD" Stroke="#5A636B" StrokeThickness="1" />
        </telerik:InformationLayer.HighlightFill>
    </telerik:InformationLayer>
</telerik:RadMap>

My shape files are also located in a folder at the root level of my TexasMap Silverlight application. I downloaded the files from the NGS Archive Shapefile website. 
0
Jeremy
Top achievements
Rank 1
answered on 03 Feb 2011, 09:57 PM
I fixed it!  For me, it was a matter of 2 things: 1) the project is DynamicsMaps, not DynamicMap.  The second, I needed to change the shp and dbf files' build action to Resource.  After that, they were there.

I hope this helps you too, Lyndsay.  Good luck!
0
Lyndsay
Top achievements
Rank 1
answered on 03 Feb 2011, 10:46 PM
Jeremy--

Thanks for sharing. I had already set the build action to "Resource" with no luck. I'm using Rad Controls for Silverlight Q3 SP1 and this is the error I get:

System.FormatException
Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Telerik.Windows.Controls.Map.DbfReader.GetNextRecord() in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\ShapeFile\DbfReader\DbfReader.cs:line 123
   at Telerik.Windows.Controls.Map.DbfReader.MoveNext() in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\ShapeFile\DbfReader\DbfReader.cs:line 133
   at Telerik.Windows.Controls.Map.ShapeFileReader.GetExtendedData(DbfReader dbfReader) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\ShapeFile\ShapeFileReader.cs:line 170
   at Telerik.Windows.Controls.Map.ShapeFileReader.GetShape(EndianBinaryReader reader, DbfReader dbfReader, List`1 list) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\ShapeFile\ShapeFileReader.cs:line 124
   at Telerik.Windows.Controls.Map.ShapeFileReader.GetShapes(EndianBinaryReader reader, ShapeFileHeader header, DbfReader dbfReader) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\ShapeFile\ShapeFileReader.cs:line 105
   at Telerik.Windows.Controls.Map.ShapeFileReader.Read(Stream shapeStream, Stream dbfStream, ExtendedPropertySet extendedPropertySet, Encoding encoding) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\ShapeFile\ShapeFileReader.cs:line 79
   at Telerik.Windows.Controls.Map.MapShapeReader.ReadShapeFileByType(ShapeReaderStatus status) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\Layers\MapShapeReader.cs:line 775
   at Telerik.Windows.Controls.Map.MapShapeReader.CompleteReading(ShapeReaderStatus status, Exception error) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\Layers\MapShapeReader.cs:line 690
   at Telerik.Windows.Controls.Map.MapShapeReader.CheckComplete(Exception serviceError, Object userState, Stream stream, Boolean data) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\Layers\MapShapeReader.cs:line 654
   at Telerik.Windows.Controls.Map.MapShapeReader.ReadData(Uri dataUri, ShapeReaderStatus userState) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\Layers\MapShapeReader.cs:line 581
   at Telerik.Windows.Controls.Map.MapShapeReader.Read(Uri uri, Uri dataUri) in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\Layers\MapShapeReader.cs:line 421
   at Telerik.Windows.Controls.Map.MapShapeReader.Read() in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\Layers\MapShapeReader.cs:line 363
   at Telerik.Windows.Controls.Map.MapShapeReader.StartRead() in c:\Builds\WPF_Scrum\Release_SL\Sources\Development\Controls\DataVisualization\Map\Layers\MapShapeReader.cs:line 588
0
Andrey
Telerik team
answered on 04 Feb 2011, 10:31 AM
Hello Jeremy Tucker,

First of all you should be sure that your files are included to your project as Resource:
1. Select world.shp and world.dbf in the solution explorer.
2. Go to the "Properties" window.
3. Check that "Build Action" set to "Resource".

Also you can check that the shapes have been read successfully.
The MapShapeReader contains the PreviewReadCompleted and ReadCompleted events. You can use one of them to check error if it occurs during the reading.
The sample code is below.

<telerik:MapShapeReader Source="/DynamicsMap;component/Resources/world.shp" DataSource="/DynamicsMap;component/Resources/world.dbf" ToolTipFormat="CNTRY_NAME" PreviewReadCompleted="MapShapeReader_PreviewReadCompleted"/>
</telerik:InformationLayer.Reader >
private void MapShapeReader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
{
    if (eventArgs.Error != null)
    {
        // eventArgs.Error.Message contains information about error
    }
}

Greetings,
Andrey Murzov
the Telerik team

Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Madhuri Gokhale
Top achievements
Rank 1
answered on 21 Feb 2011, 08:04 AM
Hi Andrey,

I am facing similar issues with the map control. I checked the shape files are included as resource files. 
Also I am able to see the number of shapes inside the shape files. There is no error while loading the files. 
But still I am unable to load the map. 

<telerik:RadMap x:Name="radMap"
UseDefaultLayout="False"
                        Grid.Row="1"
                        Grid.Column="0"
                        Center="200,200"
ZoomLevel="13"
                        Width="784"
                        Height="484">
            <telerik:RadMap.Provider>
                <telerik:EmptyProvider MinZoomLevel="1" MaxZoomLevel="13" />
            </telerik:RadMap.Provider>
            <telerik:InformationLayer x:Name="informationLayer">
                <telerik:InformationLayer.Reader>
                    <telerik:MapShapeReader ClearLayer="True" 
                                            PreviewReadCompleted="MapShapeReader_PreviewReadCompleted"
                                            Source="/TestingMap;component/ShapeFiles/18Feb11/Brighton.shp">
                    </telerik:MapShapeReader>
                </telerik:InformationLayer.Reader>
            </telerik:InformationLayer>
        </telerik:RadMap>

        private void MapShapeReader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
        {
// No error is getting caught at this point. 
            if (eventArgs.Error != null)
            {

            }
}

Only thing that I observe is the MapPolygon object does not have height and width. 

Error thrown at design time is 
System.InvalidOperationException
An unhandled exception was encountered while trying to render the current silverlight project on the design surface. To diagnose this failure, please try to run the project in a regular browser using the silverlight developer runtime.
   at Microsoft.Windows.Design.Platform.SilverlightViewProducer.OnUnhandledException(Object sender, ViewUnhandledExceptionEventArgs e)
   at Microsoft.Windows.Design.Platform.SilverlightViewProducer.OnViewUpdated()
   at Microsoft.Windows.Design.Platform.ViewProducerBase.<get_DesignModeValueProviderService>b__7(IInstanceBuilderContext invokingContext)
   at MS.Internal.Services.DesignModeValueProviderService.<ScheduleViewUpdate>b__0(Object argument)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)


 
System.ArgumentException
Value does not fall within the expected range.
   at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
   at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
   at MS.Internal.XcpImports.UIElement_UpdateLayout(UIElement element)
   at Microsoft.Windows.Design.Platform.SilverlightViewProducer.OnViewUpdated()

Please suggest.

Thanks & Regards
Madhuri
0
Andrey
Telerik team
answered on 23 Feb 2011, 08:51 AM
Hi Lyndsay,

Currently the map control supports Mercator projection with real world's geographic coordinates in degrees only (-85/85 latitude and -180/180 longitude). It is known as WGS 84 or EPSG:4326.
I'm not sure what a coordinate system is used in your shape file, but it should be converted to EPSG:4326 before using with the map control.

Kind regards,
Andrey Murzov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Shawn
Top achievements
Rank 1
answered on 12 Aug 2013, 06:39 PM
Hi,

when I'm trying to call: ShapeFileReader.Read(shpfile, dbffile)
I get FormatException:
"Input string was not in a correct format."
The details says: "When converting a string to Datetime, parse the string to take the date before putting each variable into the DateTime object."

It seems is a parsing issue. Can you suggest solution pls?

Thanks a lot.
0
Andrey
Telerik team
answered on 13 Aug 2013, 12:31 PM
Hello Shawn,

You can specify your own set of properties including a type of each property which should be read by the ShapeFileReader. So, you can specify the date-time field as the property of the string type.
You don't need to specify all DBF fields. You can specify only the fields which are required in your application.
The sample code is below.
ExtendedPropertySet properties = new ExtendedPropertySet();
properties.RegisterProperty("Field #1", "Field #1", typeof(string), string.Empty);
properties.RegisterProperty("Field #2", "Field #2", typeof(string), string.Empty);
 
List<FrameworkElement> shapes = ShapeFileReader.Read(shpfile, dbffile, properties);

Regards,
Andrey Murzov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Map
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Lyndsay
Top achievements
Rank 1
Jeremy
Top achievements
Rank 1
Andrey
Telerik team
Madhuri Gokhale
Top achievements
Rank 1
Shawn
Top achievements
Rank 1
Share this question
or