saman
saman

Reputation: 91

offline google map with gps for android

i had made a full map it works properly when i am connected to internet but i want to use the map even if there is no internet connection and also it must show me my geographical location which works best with online map. now my question is that do i have to make again a new project for offline map with new implementations or i can use my own map offline with some changes in it. please guide me in both the situations that what i have to do next.

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

    }

        }

Upvotes: 0

Views: 605

Answers (1)

Fido
Fido

Reputation: 595

You can't display google map without internet. You can try OSMDroid which can display offline titles.

Upvotes: 2

Related Questions