How-to reset state of RadMap control?

2 posts, 0 answers
  1. Peter
    Peter avatar
    64 posts
    Member since:
    Oct 2016

    Posted 24 Jan Link to this post

    Our application has to display various different map background layers. We use both MercatorProjection and EPSG900913Projection depending on which map we are displaying. Furthermore we use EPSG900913Projection to display data from an image file, using a custom provider derived from UriImageProvider. For this scenario we need to be able to set a maximum zoom level of 30. When switching between different map backgrounds we try to reset the state of the map control. These are the steps we take to try and do this:

    //Workaround for modern client crash when disposing telerik control (switching between maps)
    if (RadMap?.Items?.Count > 0)
        foreach (var radMapItem in RadMap.Items)
            var visualizationLayer = radMapItem as VisualizationLayer;
    // Reset state of RadMap
    RadMap.ItemsSource = null;
    foreach (var provider in RadMap.Providers)
    RadMap.Provider = null;
    // if we're re-using this control we must change the min/max zoom before changing spatial reference
    RadMap.MinZoomLevel = MapConstants.DefaultMapMinZoomLevel;
    RadMap.MaxZoomLevel = MapConstants.DefaultMapMaxZoomLevel;
    _defaultMinZoomLevel = MapConstants.DefaultMapMinZoomLevel;
    _defaultMaxZoomLevel = MapConstants.DefaultMapMaxZoomLevel;
    // we need to set the zoom level to a value in the allowable zoom range
    // before assigning another background
    RadMap.ZoomLevel = MapConstants.DefaultMapMinZoomLevel;
    RadMap.SpatialReference = new MercatorProjection();
    MiniMap.SpatialReference = new MercatorProjection();
    RadMap.GeoBounds = new LocationRect();
    RadMap.Center = new Location();
    RadMap.GeoBoundsNW = Location.Empty;
    RadMap.GeoBoundsSE = Location.Empty;


    Unfortunately this doesn't always seem to work. In particular I notice that this does not set the GeographicalBounds back the the initial state (I don't know if this is significant). It won't be easy to create a sample app to try and isolate this problem but if you have any suggestions on how better to restore the map control to it's initial state I'd appreciate it.





  2. Petar Mladenov
    Petar Mladenov avatar
    3145 posts

    Posted 29 Jan Link to this post

    Hi Peter,

    Can you tell me which are the properties that have unexpected values on load ? From your code I can see an empty locations for the geo-bounds-properties. Can you give me a picture of what happens on load ? Also you can try to isolate part of your code, for example try to reproduce the issue with a single layer that is remove and re-added to the map. This will generally help me get better understanding of the scenario.

    Also I noticed a workaround for a fix we already included in our product in 2017. What is the version that you use now ? Can you try your scenario with our latest official version - R1 2020 ?

    Petar Mladenov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top