如何将camra移动到android中谷歌地图v2中的特定标记 [英] how to move camra to a specific marker in google maps v2 in android

查看:124
本文介绍了如何将camra移动到android中谷歌地图v2中的特定标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当第一次使用者正在查看地图时,我可以显示标记并显示缩放和相机设置。但是我的要求是,如果用户在他/她访问期间离开该标记位置(标记离开屏幕),则将相机移动到相同的标记位置(当用户需要时)。

I am able to display a marker as well as showing it with zoom and camera setting when first time user is viewing the map. But my requirement is to move the camera to same marker position(when user want) if user goes away from that marker position(marker gets off-screen) during his/her visit.

推荐答案

感谢回复,
,但我正在寻找一些本地Map组件来执行地图标记重置任务,而不是外部按钮来导航回所需的标记位置。使用下面的代码: - $ / $>

Thanks for replies, but i was looking for some native Map component to perform the map marker reset task rather than an external button to navigate back to desired marker location. I got this working with the latest update in Map Api(to have setOnMyLocationButtonClickListener) Using below code:-

mMap.setMyLocationEnabled(true);
    LatLng markerLoc=new LatLng(companyDetail.getLatitude(), companyDetail.getLongitude());
    final CameraPosition cameraPosition = new CameraPosition.Builder()
    .target(markerLoc)      // Sets the center of the map to Mountain View
    .zoom(13)                   // Sets the zoom
    .bearing(90)                // Sets the orientation of the camera to east
    .tilt(30)                   // Sets the tilt of the camera to 30 degrees
    .build();                   //
    mMap.addMarker(new MarkerOptions().position(new LatLng(companyDetail.getLatitude(), companyDetail.getLongitude())).title("Marker"));
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    mMap.setOnMyLocationButtonClickListener(new OnMyLocationButtonClickListener() {
        @Override
        public boolean onMyLocationButtonClick() {
            mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
            return true;
        }
    });

这篇关于如何将camra移动到android中谷歌地图v2中的特定标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆