Question

I want to use a custom button to change camera focus to my current location. I am using ImageButton and trying to add it to setOnMyLocationButtonClickListener(this) but i can't. What should i do to use method of OnMyLocationButtonClickListener interface.

Here's the code:

    public class MainActivity extends Activity implements OnMyLocationButtonClickListener {
    ...
    getMyLocation = (ImageButton) findViewById(R.id.getMyLocation_button);

    getMyLocation.setOnMyLocationButtonClickListener(this); 
//gives error: setOnMyLocationButtonClickListener() is undefined

Please help, thanks!

Was it helpful?

Solution

Instead you can add the following code to your ImageButton listener.

LatLong coordinates = new LatLng(yourLatitude,yourLongitude);
yourMap.animateCamera(CameraUpdateFactory.newLatLngZoom(coordinates,zoomLevel));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top