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

  • Home
  • SEARCH
  • 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 9075993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:00:22+00:00 2026-06-16T19:00:22+00:00

I am showing an image in an UIImageView and i’d like to convert coordinates

  • 0

I am showing an image in an UIImageView and i’d like to convert coordinates to x/y values so i can show cities on this image.
This is what i tried based on my research:

CGFloat height = mapView.frame.size.height;
CGFloat width = mapView.frame.size.width;


 int x =  (int) ((width/360.0) * (180 + 8.242493)); // Mainz lon
 int y =  (int) ((height/180.0) * (90 - 49.993615)); // Mainz lat


NSLog(@"x: %i y: %i", x, y);

PinView *pinView = [[PinView alloc]initPinViewWithPoint:x andY:y];

[self.view addSubview:pinView];

which gives me 167 as x and y=104 but this example should have the values x=73 and y=294.

mapView is my UIImageView, just for clarification.

So my second try was to use the MKMapKit:

CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(49.993615, 8.242493);
MKMapPoint point = MKMapPointForCoordinate(coord);
NSLog(@"x is %f and y is %f",point.x,point.y);

But this gives me some really strange values:
x = 140363776.241755 and y is 91045888.536491.

So do you have an idea what i have to do to get this working ?

Thanks so much!

  • 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-16T19:00:24+00:00Added an answer on June 16, 2026 at 7:00 pm

    To make this work you need to know 4 pieces of data:

    1. Latitude and longitude of the top left corner of the image.
    2. Latitude and longitude of the bottom right corner of the image.
    3. Width and height of the image (in points).
    4. Latitude and longitude of the data point.

    With that info you can do the following:

    // These should roughly box Germany - use the actual values appropriate to your image
    double minLat = 54.8;
    double minLong = 5.5;
    double maxLat = 47.2;
    double maxLong = 15.1;
    
    // Map image size (in points)
    CGSize mapSize = mapView.frame.size;
    
    // Determine the map scale (points per degree)
    double xScale = mapSize.width / (maxLong - minLong);
    double yScale = mapSize.height / (maxLat - minLat);
    
    // Latitude and longitude of city
    double spotLat = 49.993615;
    double spotLong = 8.242493;
    
    // position of map image for point
    CGFloat x = (spotLong - minLong) * xScale;
    CGFloat y = (spotLat - minLat) * yScale;
    

    If x or y are negative or greater than the image’s size, then the point is off of the map.

    This simple solution assumes the map image uses the basic cylindrical projection (Mercator) where all lines of latitude and longitude are straight lines.

    Edit:

    To convert an image point back to a coordinate, just reverse the calculation:

    double pointLong = pointX / xScale + minLong;
    double pointLat = pointY / yScale + minLat;
    

    where pointX and pointY represent a point on the image in screen points. (0, 0) is the top left corner of the image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have UIImageView in which I'm showing 50x100 image. I want to show only
I have a UIImageView showing a image that is larger than it's frame. It's
Is it possible to add image in an UIAlertView, like showing an image from
Please visit this link Click on first Image. Now is showing the Modal page
In my RootViewController, I set an image as a rightBarButtonItem exactly like this, but
I have a UIImageView showing an image with the contentMode of UIViewContentModeScaleAspectFill. Then I
I have created a UIImageview programmatically, and I am showing an image from a
I have a view where I am showing image and image name in a
I have image Array with two images out of that first image its showing
OpenCV version 2.2, C++ interface. When showing a loaded image in a window with

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.