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

MapItemsRequest - The calling thread must be STA, because many UI components require this.

2 Answers 629 Views
Map
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 10 Feb 2016, 12:55 PM

Hello,

 i try to use the MapItemsRequest with the MapPolyline and i have this issue: The calling thread must be STA, because many UI components require this.

public void MapItemsRequest(object sender, MapItemsRequestEventArgs eventArgs)
        {
             
            double minZoom = eventArgs.MinZoom;
            Location upperLeft = eventArgs.UpperLeft;
            Location lowerRight = eventArgs.LowerRight;
 
            if(minZoom == 10){
                //GET INFORMATION FROM URL (DownloadString - JSON and parse information)
                var points = new LocationCollection();
                foreach (var coord in feature["geometry"]["coordinates"])
                {
                  points.Add(new Location((double) coord[1], (double) coord[0]));
                }
 
                var _polyline = new MapPolyline
                {
                   Points = points,
                   Stroke = new SolidColorBrush(Colors.Brown),
                   Name = "id" + feature["_id"],
                   StrokeThickness = 3
                };
 
                FeaturesList.Add(_polyline);
                eventArgs.CompleteItemsRequest(_trackList);
            }

2 Answers, 1 is accepted

Sort by
0
Julien
Top achievements
Rank 1
answered on 11 Feb 2016, 12:51 PM
I created a new post on stackexchange... 
0
Petar Mladenov
Telerik team
answered on 15 Feb 2016, 09:09 AM
Hi Julien,

This framework error might occur if you are using the RadMap with Visualizationlayer's virtualization inside WinForms control (via ElementHost). Generally, In Winforms you can work with UI controls only from the main UI thread.

In your case, I think the UI controls you use in the method are "_polyline" and "FeaturesList". You can try execute this code in Dispatcher.BeginInvoke() block. Also, if you are using VisualizationLayer (VizLayer), you should work with Map Shape Data objects (which are not UI Controls). The MapPolyline control is typical for InformationLayer and should not be used in VizLayer.


Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Map
Asked by
Julien
Top achievements
Rank 1
Answers by
Julien
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or