This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

misaligned coordinates android

0

Hi I am making an android app which uses an OpenStreetMap. I have my own tile server which serves the street map.

When I tell the app to centre on a specifc area on the map by passing in the coordinates as a GeoPoint, it centres somewhere around Africa when it should centre on Edinburgh.

Here is the code:

// osm map view 
MapView osmMap;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    osmMap = (MapView) findViewById(R.id.mapview);
    osmMap.setMultiTouchControls(true);

    // Create custom map source pointing to Tile Server
    XYTileSource myMapSource = new XYTileSource("myMap", null, 0, 16, 256, ".png", Constants.LOCAL_SERVER_URL);

    // Set the source and default map coordinates/zoom
    osmMap.setTileSource(myMapSource);

    osmMap.getController().animateTo(new GeoPoint(55.95223359877632*1e6, -3.188550710678032*1e6));
    osmMap.getController().setZoom(Constants.DEFAULT_ZOOM); 
}

Anyone know how I can get the coorindates to align with the map correctly?

Thanks

asked 29 Oct '12, 15:07

srose's gravatar image

srose
161101016
accept rate: 0%


One Answer:

2

If your map is centering off the african coast around here: https://www.openstreetmap.org/?mlat=0&mlon=0&zoom=4&layers=M

Then your coordinates are not working correctly. that location is the 0,0 of lat/long. Do a thorough check on whether your GeoPoint is working properly

answered 30 Oct '12, 09:34

samlarsen1's gravatar image

samlarsen1
1244512
accept rate: 50%

Source code available on GitHub .