离线谷歌地图与GPS安卓



>我已经制作了一张完整的地图,当我连接到互联网时它可以正常工作,但即使没有互联网连接,我也想使用地图,而且它必须向我显示我的地理位置最适合在线地图。 现在我的问题是,我是否必须使用新的实现再次为离线地图制作一个新项目,或者我可以离线使用自己的地图进行一些更改在其中。请在我接下来必须做的两种情况下指导我。

       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();
    }
        }

没有互联网,您无法显示谷歌地图。您可以尝试可以显示离线标题的OSMDroid。

最新更新