ZoomButtonsController.OnZoomListener help *solved*

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

ZoomButtonsController.OnZoomListener help *solved*

Postby mistajase » Wed Mar 17, 2010 6:53 pm

I've almost finished my first app but i have a small problem, basically my app displays various markers. Everything is working but I want to change the icons at different zoom levels.

I can get the current zoom level with :

Code: Select all
myZoomLevel = mapView.getZoomLevel


and I can change the icons with :

Code: Select all
if (myZoomLevel >=5) {
       
       
        this.defaultMarker = getResources().getDrawable(R.drawable.stageiconlarge);
        this.defaultMarker.setBounds(0, 0, this.defaultMarker.getIntrinsicWidth(), this.defaultMarker
            .getIntrinsicHeight());
        }else{
            this.defaultMarker = getResources().getDrawable(R.drawable.stageiconsmall);
             this.defaultMarker.setBounds(0, 0, this.defaultMarker.getIntrinsicWidth(), this.defaultMarker
                 .getIntrinsicHeight());
           
        };



But I need to set up a listener to detect when the user clicks on the zoom controls so the icons will change on zoom in or zoom out. I know it contains ZoomButtonsController.OnZoomListener but i'm not sure how to implement this type of listener (i'm a noob). It seems to be different from normal button onclicklisterners.

Can anyone help? or provide a quick example?

Thanks in advance!
Last edited by mistajase on Wed Mar 17, 2010 10:48 pm, edited 1 time in total.
mistajase
Junior Developer
Junior Developer
 
Posts: 20
Joined: Thu Nov 26, 2009 4:28 am

Top

Postby mistajase » Wed Mar 17, 2010 10:47 pm

I managed to solve this myself! :D

heres an quick example, it just displays the zoom level but i can rework it to change the marker icons.

Code: Select all
zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
        zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                        mapController.zoomIn();
                        ShowZoomLevel();
                }
        });
        zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                        mapController.zoomOut();
                        ShowZoomLevel();
                }
        });


cheers anywayz guys!
mistajase
Junior Developer
Junior Developer
 
Posts: 20
Joined: Thu Nov 26, 2009 4:28 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests