# How to transfer between screen coordinate (x,y) positions and map location (latitude, langitude) pairs using Unfolding map?

**URL:** <https://discourse.processing.org/t/how-to-transfer-between-screen-coordinate-x-y-positions-and-map-location-latitude-langitude-pairs-using-unfolding-map/9089>\
**Category:** Libraries\
**Created:** [March 7, 2019, 6:25pm UTC](https://discourse.processing.org/t/how-to-transfer-between-screen-coordinate-x-y-positions-and-map-location-latitude-langitude-pairs-using-unfolding-map/9089 "2019-03-07T18:25:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kkxxbdm](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kkxxbdm](https://discourse.processing.org/u/kkxxbdm)\
**Post date:** [March 7, 2019, 6:25pm UTC](https://discourse.processing.org/t/how-to-transfer-between-screen-coordinate-x-y-positions-and-map-location-latitude-langitude-pairs-using-unfolding-map/9089/1 "2019-03-07T18:25:45Z")

</div>

This is really a simple/naive question, but I’m fairly new and please be kind with your responses. More specifically,

![screenCoord](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/571e3885839e8c016c4d6982684864d51a45e89e.png)

the above image explains the screen (x,y) coordinates.

 ![map](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8effe9076263dcb1785d06a3fe85173eb30bcbf8.jpeg)

the second image above explains the map location (latitude, longitude) pairs in the map.

I’d like to know how to transfer between the two. For example, given the (x,y) coordinates, how to get the corresponding (latitude, longitude) pair in the map? On the other hand, given the (latitude, longitude) pair, how to get its corresponding (x,y) coordinate in the screen?

I think this might have something to do with the zoom level of the map? Any comments are greatly appreciated. Many thanks !

---

<div class="post-metadata">

**Author:** ![f42ter](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/f42ter/32/16793_2.png) [@f42ter](https://discourse.processing.org/u/f42ter)\
**Post date:** [March 7, 2019, 9:36pm UTC](https://discourse.processing.org/t/how-to-transfer-between-screen-coordinate-x-y-positions-and-map-location-latitude-langitude-pairs-using-unfolding-map/9089/2 "2019-03-07T21:36:20Z")

</div>

What exactly are you looking for. Last year I start to work on a Processing library for a similar purpose. Not finalised and published cause it is based on a JAVASCRIPT implementation and I’ve only implemented that parts I’m interested in.

I’ll check it this weekend an came back to you.  
Sorry for the delay. You may find some ideas based on [http://www.movable-type.co.uk/latlong.html](http://www.movable-type.co.uk/latlong.html)  
I’m still working on the processing library implementation.  
Transformation between screen and work coordinates is than an other issue to be solved.

---

<div class="post-metadata">

**Author:** ![kkxxbdm](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kkxxbdm](https://discourse.processing.org/u/kkxxbdm)\
**Post date:** [March 8, 2019, 7:11am UTC](https://discourse.processing.org/t/how-to-transfer-between-screen-coordinate-x-y-positions-and-map-location-latitude-langitude-pairs-using-unfolding-map/9089/3 "2019-03-08T07:11:29Z")

</div>

I’m getting closer, based on this link: [http://unfoldingmaps.org/javadoc/de/fhpotsdam/unfolding/utils/ScreenPosition.html](http://unfoldingmaps.org/javadoc/de/fhpotsdam/unfolding/utils/ScreenPosition.html)

---

<div class="post-metadata">

**Author:** ![kkxxbdm](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kkxxbdm](https://discourse.processing.org/u/kkxxbdm)\
**Post date:** [March 8, 2019, 7:55am UTC](https://discourse.processing.org/t/how-to-transfer-between-screen-coordinate-x-y-positions-and-map-location-latitude-langitude-pairs-using-unfolding-map/9089/4 "2019-03-08T07:55:52Z")

</div>

In a general case, the following link [https://stackoverflow.com/questions/7019101/convert-pixel-location-to-latitude-longitude-vise-versa](https://stackoverflow.com/questions/7019101/convert-pixel-location-to-latitude-longitude-vise-versa) might be what I need. On the other hand, based on Unfolding map, this wonderful `map.getScreenPosition(location)` might be what I need. 😉
