Lucas Lisbon Lucas Lisbon - 1 year ago 132
Android Question

How to zoom to specific marker — osmdroid API (version 5.2@aar)

Marker example:

Marker m = new Marker(mapOSM);
m.setSnippet("bla bla bla);
m.setPosition(new GeoPoint(cenario.getLatitude(), cenario.getLongitude()));

Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_place, null);
icon.setColorFilter(getResources().getColor(R.color.md_green_400), PorterDuff.Mode.MULTIPLY);



I know how to animate to a position:


But how to zoom to a specific marker??

Answer Source

Ugly solution:

Do it


And then do it

    new Handler().postDelayed(new Runnable() {
        public void run() {
            mapOSM.getController().animateTo(new GeoPoint(x, y));
    }, 300);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download