About Provider And Dynamic Layer

5 posts, 1 answers
  1. volkan
    volkan avatar
    5 posts
    Member since:
    May 2008

    Posted 27 Oct 2010 Link to this post

    I Have 2 questions
    I create my own provider.
    1-> I have a bug on my provider that when i use the following code to set the map center 
    this.PergoMap.Center = new Location { Latitude = 78.174140351324, Longitude = 32.8532699990176 };
    it is showing incorrect point and the coordinates location is
     Latitude = 39.087070175662, Longitude = 32.8532699990176
    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls.Map;
    using System.Text;
     
    namespace Pergo.Silver.Views.ctrl
    {
        public class PergoProvider : MapProviderBase
        {
             
            public string mapServiceUrl { get; set; }
            public string Token { get; set; }
     
            public PergoProvider(MapMode mode, bool labelVisible) :
                base(mode, labelVisible)
            {
                mapServiceUrl = @"map{0}.pergo.com.tr";
            }
            #region .. Long-lat Max-Min
            public override double MinLatitude
            {
                get
                {
                    return -85.05112878;//base.MinLatitude;
                }
            }
           public override double MaxLatitude
           {
               get
               {
                   return 85.05112878; //base.MaxLatitude;
               }
           }
           public override double MaxLongitude
           {
               get
               {
                   return 180.0;//base.MaxLongitude;
               }
           }
           public override double MinLongitude
           {
               get
               {
                   return -180.0;// base.MinLongitude;
               }
           }
            #endregion
           public override MapProviderBase GetSource(MapMode mode, bool isLabelVisible)
            {
                return this;
            }
            public override ISpatialReference SpatialReference
            {
                get
                {
                    return new MercatorProjection();
                }
     
            }
            public override Size TileSize
            {
                get
                {
                    return new Size(base.TileSize.Width , base.TileSize.Height);
                }
            }
             
            public override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
            {
                int zoomLevel = this.ConvertTileToZoomLevel(tileLevel) - 1;
                if (zoomLevel == -1)
                    return null;
                string URL = "";
                double nullvalue = Math.Pow(2, Convert.ToDouble(zoomLevel))-1;
                if (tilePositionY > nullvalue)
                    return null;
                else tilePositionY = Convert.ToInt32(nullvalue) - tilePositionY;
     
                string x = tilePositionX.ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001
                string y = tilePositionY.ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000
                URL = string.Format("http://" + mapServiceUrl + "/tile/{1:00}/{2}/{3}.png", GetServerNum(tilePositionX, tilePositionY, 4), zoomLevel, x, y);
                //URL = string.Format("http://" + "map0.pergo.com.tr" + "/tile/{0:00}/{1}/{2}.png", zoomLevel, x, y);
               return new Uri(URL);
     
            }
            internal int GetServerNum(int tilePositionX,int tilePositionY, int max)
            {
                return (tilePositionX + 2 * tilePositionY) % max;
            }
     
             
            public override void Initialize()
            {
                     
            }
     
            public override bool IsLabelSupported
            {
                get { return false; }
            }
     
     
            public override bool IsModeSupported(MapMode mode)
            {
                return false;
            }
     
             
            public override System.Collections.Generic.IEnumerable<MapMode> SupportedModes
            {
                get { return null; }
            }
            public override int MaxZoomLevel
            {
                get
                {
                    return base.MaxZoomLevel;
                }
                set
                {
                    base.MaxZoomLevel = value;
                }
            }
            public override int MinZoomLevel
            {
                get
                {
                    return base.MinZoomLevel;
                }
                set
                {
                    base.MinZoomLevel = value;
                }
            }
            protected override bool IsValidTileLevel(int tileLevel)
            {
                return base.IsValidTileLevel(tileLevel);
            }
            protected override void OnMapModeChanged(MapMode oldMode, MapMode newMode)
            {
     
            }
     
     
        }
    }


    1-> When i adding content control to my map it is looking upper left side on the map control and
    when i change the map center they also sliding with map.

    internal void clnt_GetAllTerminalCompleted(object sender, PergoWCF.GetAllTerminalCompletedEventArgs e)
           {
               const string DefaultStyle = "defaultStyle";
     
               List<object> objects = new List<object>();
     
               if (e.Error == null)
               {
                   foreach (Terminal terminalLocation in e.Result)
                   {
                       ContentControl terminal = new ContentControl();
                       terminal.DataContext = terminalLocation.ShortName;
                       string styleName = DefaultStyle;
                       styleName = "marketStyle";
     
                       if (this.dynamicLayer.Items.Contains(terminal))
                           continue;
     
                       try
                       {
                           terminal.Style = this.PergoMap.Resources[styleName] as Style;
                       }
                       catch (Exception)
                       {
                           terminal.Style = this.PergoMap.Resources[DefaultStyle] as Style;
                       }
     
                       terminal.SetValue(MapLayer.LocationProperty,
                           new Telerik.Windows.Controls.Map.Location(Convert.ToDouble(terminalLocation.Latitude), Convert.ToDouble(terminalLocation.Longitude)));
     
                       ToolTip tooltip = new ToolTip();
     
                       tooltip.Content = "Click to select";
                       terminal.MouseLeftButtonDown += new MouseButtonEventHandler(area_MouseLeftButtonDown);
     
                       //else
                       //{
                       //    tooltip.Content = "Click to select or unselect";
                       //    store.MouseLeftButtonDown += new MouseButtonEventHandler(store_MouseLeftButtonDown);
                       //}
     
                       ToolTipService.SetToolTip(terminal, tooltip);
     
                       objects.Add(terminal);
                   }
     
                   Action<System.Collections.ICollection> callback = e.UserState as Action<System.Collections.ICollection>;
     
                   callback(objects);
               }
           }

    public class DynamicSource : IMapDynamicSource
        {
            private Map page;
     
     
            public DynamicSource(Map examplePage)
            {
                this.page = examplePage;
            }
     
            /// <summary>
            /// The method requests data from the web service according to zoom level and location area
            /// </summary>
            /// <param name="minZoom">Minimal zoom.</param>
            /// <param name="maxZoom">Maximal zoom.</param>
            /// <param name="upperLeft">Upper left coordinate.</param>
            /// <param name="lowerRight">Lower right coordinate.</param>
            /// <param name="callback">Callback.</param>
            public void ItemsRequest(double minZoom, double maxZoom, Telerik.Windows.Controls.Map.Location upperLeft, Telerik.Windows.Controls.Map.Location lowerRight, Action<System.Collections.ICollection> callback)
            {
     
     
                PergoWCF.WCFClient client = new WCFClient();
                client.GetAllTerminalCompleted += page.clnt_GetAllTerminalCompleted;
     
                if (minZoom == 3)
                {
                    // request areas
                    try
                    {
                        client.GetAllTerminalAsync(callback);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
     
                if (minZoom == 9)
                {
                    // request stores
                    try
                    {
                        client.GetAllTerminalAsync(callback);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
    }


  2. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 29 Oct 2010 Link to this post

    Hello volkan,

    Your custom provider does not perform the initialize process. It should be done using the IsInitialized property. It allows you to initialize the provider and the dynamic layer will place added objects correctly. Also it should return empty collection from the SupportedModes method instead of null.
    public class PergoProvider : MapProviderBase
    {
        private bool initialized;
      
        // ...
      
        public override void Initialize()
        {
            this.initialized = this.IsInitialized;
        }
      
        // ...
      
        public override System.Collections.Generic.IEnumerable<MapMode> SupportedModes
        {
            get { return new Collection<MapMode>(); }
        }
      
        // ...
    }


    Another problem is in the tile system on server side. It contains images which cover the map partially. For example the first zoom level requires four 256x256 images to cover the map as 2x2 dimensional grid, but your tile server provides two images only.
    Currently the map control does not allow a behavior for using disproportional image as a whole map.

    Kind regards,
    Andrey Murzov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. volkan
    volkan avatar
    5 posts
    Member since:
    May 2008

    Posted 03 Nov 2010 Link to this post

    My problem solved with your advice.
    Thanks for answer.
  5. volkan
    volkan avatar
    5 posts
    Member since:
    May 2008

    Posted 17 Jan 2011 Link to this post

    Hi,
    I updated my project to Q3 but when i updated it, my pin point shown on map control is on the left upper side, they are not shown in true location.
    You can see them in attached picture. Their true locaion are on the Turkey.
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 20 Jan 2011 Link to this post

    Hi volkan,

    Unfortunately we aren't able to reproduce this problem. Could you, please, provide us with small apllication which we can use to check what is wrong?

    Best wishes,
    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>>
Back to Top
DevCraft banner