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!

有帮助吗?

解决方案

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

LatLong coordinates = new LatLng(yourLatitude,yourLongitude);
yourMap.animateCamera(CameraUpdateFactory.newLatLngZoom(coordinates,zoomLevel));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top