我制作了一张完整的地图,当我连接到互联网时它可以正常工作,但即使没有互联网连接,我也想使用地图,而且它必须向我显示最适合在线地图的地理位置。现在我的问题是我是否必须再次为具有新实现的离线地图创建一个新项目,或者我可以离线使用我自己的地图并对其进行一些更改。请在我接下来要做的这两种情况下指导我。
map=(MapView) findViewById(R.id.mvmain);
map.setBuiltInZoomControls(true);
touchy t=new touchy();
overlayList=map.getOverlays();
overlayList.add(t);
compass= new MyLocationOverlay(Main.this, map);
overlayList.add(compass);
controller= map.getController();
mapSearchBox = (EditText) findViewById(R.id.map);
mapSearchBox.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH ||
actionId == EditorInfo.IME_ACTION_DONE ||
actionId == EditorInfo.IME_ACTION_GO ||
event.getAction() == KeyEvent.ACTION_DOWN &&
event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
// hide virtual keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mapSearchBox.getWindowToken(), 0);
new SearchClicked(mapSearchBox.getText().toString()).execute();
mapSearchBox.setText("", TextView.BufferType.EDITABLE);
return true;
}
return false;
}
});
d =getResources().getDrawable(R.drawable.aa);
controller.setZoom(6);
//Placing pinpoint at location
lm=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria crit=new Criteria();
towers=lm.getBestProvider(crit, false);
Location location=lm.getLastKnownLocation(towers);
if(location !=null)
{
lat=(int) (location.getLatitude() *1E6);
longi=(int) (location.getLongitude() *1E6);
GeoPoint ourLocation= new GeoPoint(lat,longi);
OverlayItem overlayItem= new OverlayItem(ourLocation,"","");
CustomPinpoint custom=new CustomPinpoint(d,Main.this);
custom.insertPinPoint(overlayItem);
overlayList.add(custom);
}
else
{
Toast.makeText(Main.this,"Couldn't get provider", Toast.LENGTH_SHORT).show();
}
}