NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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%


If your map is centering off the african coast around here: http://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

permanent link

answered 30 Oct '12, 09:34

samlarsen1's gravatar image

samlarsen1
1244512
accept rate: 50%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×362
×181
×47

question asked: 29 Oct '12, 15:07

question was seen: 4,097 times

last updated: 30 Oct '12, 09:34

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum