It is necessary to make a move on the map with buttons, someone can suggest how to do this, I have not found a single tutorial on this issue, and I don’t even know how to use it. The map on the phone is displayed, now you need to add by pressing the button to go either up or down or to the right or left. Does anyone have any examples? Or at least tell me what event and how to move the map?

    3 answers 3

    Use RelativeLayout to place your buttons on top of MapView , and mapView.getController().scrollBy(x, y) to move the map:

     ... onClick(View v) { if (v == mMyCustomPanLeftButton) { mMapController.scrollBy(-15 /*x*/, 0) } } 
    • It flips through the map, but does not update the black screen instead of the map - dajver
    • It does not update, because it needs a connection with an Internet, it's an online map. will then update. - deivan_
    • Those. Initially, the map is shown, and then, by clicking, it turns into a Malevich rectangle, or is the map black at once? Try pulling mMapView.postInvalidate () after scrollBy () may be fixed. - Ivan Bartsov
    • No, when you flip through, it only reaches the point where it is loaded, and then the map does not sink, I tried to do it more conveniently via animateTo, but there’s more to do in terms of logic - dajver
    • Hmm .. yes, through animateTo will definitely be more difficult. Try invalidate () to pull (although I’ve probably tried it already) - Ivan Bartsov
     btn4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v == btn4) { GeoPoint p = mapView.getMapCenter(); GeoPoint z = new GeoPoint(p.getLatitudeE6(), p.getLongitudeE6() - 1000000); mc.animateTo(z); } } }); 

      Maybe something from the class will work?