0

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 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 coordinates to align with the map correctly?

Thanks

Origin
  • 2,009
  • 5
  • 19
  • 19
sam
  • 2,469
  • 8
  • 37
  • 57
  • 1
    I don't think the .animateTo() will work straight away. Try taking it out of the onCreate and doing it a bit latter. – Ifor Oct 29 '12 at 14:59
  • 1
    Thanks a lot. I put it after setZoom and it works great. – sam Oct 29 '12 at 15:24

0 Answers0