Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8650813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:54:45+00:00 2026-06-12T13:54:45+00:00

I am developing wpf application. I have one static world map of 500 width

  • 0

I am developing wpf application. I have one static world map of 500 width and 500 height. I have one form in my application. In this from user enters the latitude and longitude and submit the details. I want to show the exact location of these latitude and longitude on my static map. So I am trying to convert these latitude and longitude into pixels. I am using ellipse to show the circle on my static map. How should I convert the geographical coordinates into pixels in C# ? Can you please provide me any code or link through which I can solve the above issue ? My question is similar to the link

Convert long/lat to pixel x/y on a given picture

I found this link useful.

Edit :
I have used the link

http://code.google.com/p/geographical-dot-net/source/browse/trunk/GeographicalDotNet/GeographicalDotNet/Projection/GoogleMapsAPIProjection.cs

and written the following code

GoogleMapsAPIProjection googleApiProjObj = new GoogleMapsAPIProjection(0);
            float x = 18.29F;
            float y = 73.57F;
            System.Drawing.PointF p1 = new System.Drawing.PointF(x,y);
            System.Drawing.PointF p2 =googleApiProjObj.FromCoordinatesToPixel(p1);

            //CircleEllipse.Margin = new Thickness(longitudePixels,latitudePixels, 0, 0);
            CircleEllipse.Margin = new Thickness(p2.X, p2.Y, 0, 0);
            CircleEllipse.Visibility = Visibility.Visible;

18.29 and 73.57 are lat and log of Pune city in India. In the above code p2.x giving me 141 and p2.y giving me 49. So the above code not showing me the Pune location on map. My xaml code is as follows

<ScrollViewer HorizontalScrollBarVisibility="Auto" Grid.Row="4" Width="500" Height="500" Background="Gray">
            <Grid>
                <Image Margin="0,0,0,0" x:Name="MapImage" Source="Images\World-Blank-Map.png" Stretch="Fill" Width="500" Height="500" ></Image>
                <Ellipse Canvas.Top="50" 
      Canvas.Left="50" 
      Fill="Red" 
      Height="5"
      Width="5"
      Visibility="Collapsed"
      StrokeThickness="4"                     

      x:Name="CircleEllipse"
      HorizontalAlignment="Left"
      VerticalAlignment="Top"
      Margin="0,0,0,0" />
            </Grid>
        </ScrollViewer>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:54:46+00:00Added an answer on June 12, 2026 at 1:54 pm

    You provided your own answer, take a look at the code at the following

    http://code.google.com/p/geographical-dot-net/source/browse/trunk/GeographicalDotNet/GeographicalDotNet/Projection/GoogleMapsAPIProjection.cs

    public class GoogleMapsAPIProjection
    {
        private readonly double PixelTileSize = 256d;
        private readonly double DegreesToRadiansRatio = 180d / Math.PI;
        private readonly double RadiansToDegreesRatio = Math.PI / 180d;
        private readonly PointF PixelGlobeCenter;
        private readonly double XPixelsToDegreesRatio;
        private readonly double YPixelsToRadiansRatio;
    
        public GoogleMapsAPIProjection(double zoomLevel)
        {
            var pixelGlobeSize = this.PixelTileSize * Math.Pow(2d, zoomLevel);
            this.XPixelsToDegreesRatio = pixelGlobeSize / 360d;
            this.YPixelsToRadiansRatio = pixelGlobeSize / (2d * Math.PI);
            var halfPixelGlobeSize = Convert.ToSingle(pixelGlobeSize / 2d);
            this.PixelGlobeCenter = new PointF(
                halfPixelGlobeSize, halfPixelGlobeSize);
        }
    
        public PointF FromCoordinatesToPixel(PointF coordinates)
        {
            var x = Math.Round(this.PixelGlobeCenter.X
                + (coordinates.X * this.XPixelsToDegreesRatio));
            var f = Math.Min(
                Math.Max(
                     Math.Sin(coordinates.Y * RadiansToDegreesRatio),
                    -0.9999d),
                0.9999d);
            var y = Math.Round(this.PixelGlobeCenter.Y + .5d * 
                Math.Log((1d + f) / (1d - f)) * -this.YPixelsToRadiansRatio);
            return new PointF(Convert.ToSingle(x), Convert.ToSingle(y));
        }
    
        public PointF FromPixelToCoordinates(PointF pixel)
        {
            var longitude = (pixel.X - this.PixelGlobeCenter.X) /
                this.XPixelsToDegreesRatio;
            var latitude = (2 * Math.Atan(Math.Exp(
                (pixel.Y - this.PixelGlobeCenter.Y) / -this.YPixelsToRadiansRatio))
                - Math.PI / 2) * DegreesToRadiansRatio;
            return new PointF(
                Convert.ToSingle(latitude),
                Convert.ToSingle(longitude));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing wpf application in C#. I have one button on which I
I am developing a WPF application, and I have created a user control called
I am developing a WPF application, and I need your advice. I have to
I am developing an application in C# WPF which will have Client-Server architecture (Client
I'm developing a WPF application which reads and writes XML data. I'm coming from
I have an application which I am developing using WPF\Prism\MVVM. All is going well
I'm currently developing a WPF application in C# and I want to have a
I'm developing a WPF application, and I have created a custom usercontrol because I
I am developing a WPF application, and have a TextBlock which I want to
I am developing a WPF UI application . I have a menu on top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.