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

3 posts, 0 answers
  1. Julien
    Julien avatar
    11 posts
    Member since:
    Mar 2015

    Posted 10 Feb Link to this post

    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. Julien
    Julien avatar
    11 posts
    Member since:
    Mar 2015

    Posted 11 Feb in reply to Julien Link to this post

    I created a new post on stackexchange... 
  3. UI for WPF is Visual Studio 2017 Ready
  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 15 Feb Link to this post

    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
Back to Top