Centering Map on Form Load

4 posts, 0 answers
  1. Scott
    Scott avatar
    30 posts
    Member since:
    Dec 2015

    Posted 05 Dec 2016 Link to this post

     

     

            private void frmMapping_Load(object sender, EventArgs e)
            {
                string cacheFolder = @"..\..\cache";

                bingProvider.UseSession = true;
                bingProvider.BingKey = "MyKey";
                LocalFileCacheProvider cache = new LocalFileCacheProvider(cacheFolder);
                bingProvider.CacheProvider = cache;
                bingProvider.ImagerySet = Telerik.WinControls.UI.Map.Bing.ImagerySet.Road;
                this.radMap1.Providers.Add(bingProvider);

                PointG racheer = new PointG(38.595592, -90.429629);
                MapPin racheerPin = new MapPin(racheer);
                racheerPin.Text = "Right Here Man!!!";
                racheerPin.BackColor = Color.AliceBlue;

        }
  2. Scott
    Scott avatar
    30 posts
    Member since:
    Dec 2015

    Posted 05 Dec 2016 Link to this post

    OK... Posted accidentally before I was finished.
    I am trying center the map on load.  However the map is not centering when I use this code.  Please advise.

    Thank you.

    -Scott

  3. Scott
    Scott avatar
    30 posts
    Member since:
    Dec 2015

    Posted 05 Dec 2016 in reply to Scott Link to this post

    and forgot the last line of code....

    this.radMap1.MapElement.Center = racheer;

    Another suggestion...  The ability to edit Posts rather than have to write additional Reply entries.

    -Scott

  4. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 06 Dec 2016 Link to this post

    Hello Scott,

    Thank you for writing.

    First, you need to add the pin to a layer and then use the BringIntoView method: 
    private void radButton1_Click(object sender, EventArgs e)
    {
        PointG racheer = new PointG(38.595592, -90.429629);
        MapPin racheerPin = new MapPin(racheer);
        racheerPin.Text = "Right Here Man!!!";
        racheerPin.BackColor = Color.Red;
     
        this.radMap1.MapElement.Layers.Add(new MapLayer("PinLayer"));
        this.radMap1.MapElement.Layers[0].Add(racheerPin);
      
        this.radMap1.MapElement.BringIntoView(racheer);
    }

    I hope this information is useful. Let me know if you need further assistance.

    Regards,
    Dimitar
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Back to Top