问题描述:

I'll be doing an app for my thesis. My thesis is a Offline Map which includes landmarks/routing. My thesis Maps is only for my City here in the philippines. I tried to use OSMDroid and failed to produce the wanted result.

What I want is (if possible) I want this to happen in my app:

  1. Install APK
  2. Prompt the user which country he/she wants to use
  3. Download the chosen country for offline use.
  4. Done

Here's my code in OSMDroid

public class MainActivity extends Activity {

public static final GeoPoint myCity = new GeoPoint(14.54321,120.23451);

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

MapView mapView = (MapView) findViewById(R.id.map);

mapView.setClickable(true);

mapView.setBuiltInZoomControls(true);

mapView.setMultiTouchControls(true);

mapView.setUseDataConnection(true);

mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);

IMapController mapViewController = mapView.getController();

mapViewController.setZoom(13);

mapViewController.setCenter(myCity);

}

}

Here's what I've done:

  1. I Use Mobac to a portion of the map
  2. Save it to my Internal Phone Memory(i named it MapquestOSM)
  3. Run the program

But when I run the program it's just Blank.

I Don't Mind using OSMDroid again as long as it will produce the same result.

网友答案:

I'm willing to bet you didn't do anything to tell osmdroid that you want a different map source. Here's a few pointers to help

  • if you use mobac to create a zip file, it source names have to match. i.e. if you get Mapnik tiles, then use the Mapnik tile source in osmdroid. Mapquest tiles, mapquest source.
  • zip files have an upper limit in android, use sqlite instead (also head the first point).
  • tell the MapView you want offline maps (setUseDataconnection(false);)

If you still have issues (and are using zip files) try altering the contents of the zip to have the first directory = Mapnik. Then using the default tile source in osmdroid.

Until my PR gets merged (to switch tile providers at runtime) and a new release cut, that's really your only option.

Edit: osmdroid only looks in /sdcard/osmdroid/ for map tiles.

相关阅读:
Top