# map.getScreenPosition does not work as expected with unfolding maps

**URL:** <https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864>\
**Category:** Libraries\
**Created:** [November 27, 2019, 11:34am UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864 "2019-11-27T11:34:32Z")\
**Posts on this page:** 7\
**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:** [November 27, 2019, 11:34am UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864/1 "2019-11-27T11:34:32Z")

</div>

Hi. The following is the code:

```auto
// Import Unfolding Maps
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.core.*;
import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.events.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.interactions.*;
import de.fhpotsdam.unfolding.mapdisplay.*;
import de.fhpotsdam.unfolding.mapdisplay.shaders.*;
import de.fhpotsdam.unfolding.marker.*;
import de.fhpotsdam.unfolding.providers.*;
import de.fhpotsdam.unfolding.texture.*;
import de.fhpotsdam.unfolding.tiles.*;
import de.fhpotsdam.unfolding.ui.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.utils.*;

// Import some Java utilities
import java.util.Date;
import java.text.SimpleDateFormat;
UnfoldingMap map;

Location center = new Location(63, 20);
Integer zoom_start = 9;

void setup() {
 size(1000, 1000, P3D);
 smooth();
 map = new UnfoldingMap(this);
MapUtils.createDefaultEventDispatcher(this, map);
map.zoomAndPanTo(zoom_start, center);
}

void draw(){

map.draw();
fill(0,20);
rect(0,0,width,height);

Location loc = new Location(67,17);
ScreenPosition screenPos = map.getScreenPosition(loc);
println(screenPos);
}

```

When I run it, the screenposition I got is like (-687.0, -2279.0); it is outside of the screen area. I was wondering, is there anyway to improve this?

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 27, 2019, 5:04pm UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864/2 "2019-11-27T17:04:01Z")

</div>

I don‘t see your problem… it works exactly how it should… it converts a location to a position on your screen. Try using a value very close to your Center Location and you‘ll see that it will return a value between 0, 0 and 1000, 1000 (the extent of your screen).

---

<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:** [November 27, 2019, 5:36pm UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864/3 "2019-11-27T17:36:15Z")

</div>

Is there anyway to adjust the screen coordinate to accommodate the specific screen position then?

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 27, 2019, 6:14pm UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864/4 "2019-11-27T18:14:00Z")

</div>

I‘m not sure what you mean by that? What do you intend to do exactly?

---

<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:** [November 28, 2019, 10:44am UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864/5 "2019-11-28T10:44:55Z")

</div>

I’d like to do an animation of markers on the screen. Now, the markers even do not show up, because the left upper corner is (0,0) in the coordinate system and the marker I intended to draw has position (-687.0, -2279.0). So I might need to try it out by updating the latitude and longitude of the center of the map and also the size of the map. I was wondering, is there any other way around instead of trying out. Thank you for your reply.

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 28, 2019, 11:36am UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864/6 "2019-11-28T11:36:30Z")

</div>

You can just move the map so that -600, -2200 is the Center. That should solve your problem… i think.

---

<div class="post-metadata">

**Author:** ![tnagel](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@tnagel](https://discourse.processing.org/u/tnagel)\
**Post date:** [November 29, 2019, 10:41am UTC](https://discourse.processing.org/t/map-getscreenposition-does-not-work-as-expected-with-unfolding-maps/15864/7 "2019-11-29T10:41:40Z")

</div>

Not fully sure I understand what you are trying to achieve. But you could start by simply zooming out, either interactively, or use a zoom\_start of e.g. 3 so the location of 67,17 is within the visible map area.

If you want to ensure the locations are on the visible map area, you could also create a Marker with that location and then use `map.zoomAndPanToFit(myMarker)` or, if multiple markers, `map.zoomAndPanToFitMarkers(myMarkersList)`.
