Java 类android.widget.ZoomControls 实例源码

项目:Mooc-map    文件:MainActivity.java   
private void initView() {
    mMapView = (MapView) findViewById(R.id.id_bmapView);
    mBaiduMap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f);//缩放等级17=100m
    mBaiduMap.setMapStatus(msu);
    mLocationMode = MyLocationConfiguration.LocationMode.NORMAL;
    //隐藏缩放控件和百度logo
    int childCount = mMapView.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ZoomControls || child instanceof ImageView) {
            child.setVisibility(View.GONE);
        }
    }
    //改变比例尺的位置
    final int screenheight = this.getWindowManager().getDefaultDisplay().getHeight();
    mBaiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() {

        @Override
        public void onMapLoaded() {
            mMapView.setScaleControlPosition(new Point(200, screenheight - 307));
        }
    });
}
项目:mapsforge    文件:MapZoomControls.java   
MapZoomControls(Context context, final MapView mapView) {
    this.zoomControls = new ZoomControls(context);
    this.showMapZoomControls = true;
    this.zoomLevelMax = DEFAULT_ZOOM_LEVEL_MAX;
    this.zoomLevelMin = DEFAULT_ZOOM_LEVEL_MIN;
    this.zoomControls.setVisibility(View.GONE);
    this.zoomControlsGravity = DEFAULT_ZOOM_CONTROLS_GRAVITY;

    MapViewPosition mapViewPosition = mapView.getMapViewPosition();
    this.zoomControls.setOnZoomInClickListener(new ZoomInClickListener(mapViewPosition));
    this.zoomControls.setOnZoomOutClickListener(new ZoomOutClickListener(mapViewPosition));
    this.zoomControlsHideHandler = new ZoomControlsHideHandler(this.zoomControls);

    int wrapContent = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    LayoutParams layoutParams = new LayoutParams(wrapContent, wrapContent);
    mapView.addView(this.zoomControls, layoutParams);
}
项目:Mooc-map    文件:RoutePlan.java   
private void initMapView() {
    //初始化地图
    mMapView = (MapView) findViewById(R.id.map);
    mBaidumap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaidumap.setMapStatus(msu);
    mBtnPre = (Button) findViewById(R.id.pre);
    mBtnNext = (Button) findViewById(R.id.next);
    mBtnPre.setVisibility(View.INVISIBLE);
    mBtnNext.setVisibility(View.INVISIBLE);
    //隐藏缩放控件和百度logo
    int childCount = mMapView.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ZoomControls || child instanceof ImageView) {
            child.setVisibility(View.GONE);
        }
    }
    //改变比例尺的位置
    final int screenheight = this.getWindowManager().getDefaultDisplay().getHeight();
    mBaidumap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() {

        @Override
        public void onMapLoaded() {
            mMapView.setScaleControlPosition(new Point(200, screenheight - 303));
        }
    });
}
项目:FrontOne    文件:MapFragment.java   
public void initMap(){

    mMapView.removeViewAt(1);
    int childCount = mMapView.getChildCount();
    View zoom = null;
    for (int i = 0; i < childCount; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ZoomControls) {
                zoom = child;
                break;
        }
    }
    zoom.setVisibility(View.GONE);

    mBaiduMap.setMyLocationEnabled(true);

    mLocClient = new LocationClient(mContext);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setOpenGps(true);
    option.setCoorType("bd09ll");
    option.setScanSpan(1000);
    option.setIsNeedAddress(true);
    mLocClient.setLocOption(option);
    mLocClient.start();
}
项目:FrontOne    文件:MainActivity.java   
/**
 * init mapview
 */
public void initMap() {

    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    // remove map logo
    mMapView.removeViewAt(1);

    int childCount = mMapView.getChildCount();
    View zoom = null;
    for (int i = 0; i < childCount; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ZoomControls) {
            zoom = child;
            break;
        }
    }
    zoom.setVisibility(View.GONE);

    mBaiduMap = mMapView.getMap();
    UiSettings mUiSettings = mBaiduMap.getUiSettings();
    mUiSettings.setCompassEnabled(false);

    mBaiduMap.setMyLocationEnabled(true);
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setOpenGps(true);
    option.setCoorType("bd09ll");
    option.setScanSpan(1000);
    option.setIsNeedAddress(true);
    mLocClient.setLocOption(option);
    mLocClient.start();
}
项目:Zong    文件:ScoreActivity.java   
private void registerListeners() {
    //zoom buttons
    final ZoomControls zoomControls = (ZoomControls) findViewById(R.id.score_zoom);
    zoomControls.setOnZoomInClickListener(view -> {
        if (currentScalingIndex + 1 < scalings.length) {
            currentScalingIndex++;
            updateScoreView();
            //enable/disable buttons
            zoomControls.setIsZoomInEnabled(currentScalingIndex + 1 < scalings.length);
            zoomControls.setIsZoomOutEnabled(true);
        }
    });
    zoomControls.setOnZoomOutClickListener(view -> {
        if (currentScalingIndex > 0) {
            currentScalingIndex--;
            updateScoreView();
            //enable/disable buttons
            zoomControls.setIsZoomInEnabled(true);
            zoomControls.setIsZoomOutEnabled(currentScalingIndex > 0);
        }
    });
    //play button
    final Button playbackButton = (Button) findViewById(R.id.score_playback);
    playbackButton.setOnClickListener(view -> {
        playback();
        playbackButton.setText(playing ? "Stop" : "Play");
    });
}
项目:ChangTu    文件:ShareMapActivity.java   
private void initMap() {
    mMapView = (MapView) findViewById(R.id.share_map);
    mBaiduMap = mMapView.getMap();
    // 隐藏logo
    View child = mMapView.getChildAt(1);
    if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) {
        child.setVisibility(View.INVISIBLE);
    }


    //地图上比例尺
    //mMapView.showScaleControl(false);
    // 隐藏缩放控件
    mMapView.showZoomControls(true);
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(18f);
    mBaiduMap.setMapStatus(msu);
    //定位初始化
    locationClient = new LocationClient(this);
    // 设置定位的相关配置
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setOpenGps(true);
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(1000);
    locationClient.setLocOption(option);
    locationClient.registerLocationListener(new BDLocationListener() {
        @Override
        public void onReceiveLocation(final BDLocation bdLocation) {
            if (bdLocation == null || mMapView == null)
                return;
            //构造定位数据
            MyLocationData locData = new MyLocationData.Builder()
                    .accuracy(bdLocation.getRadius())
                    .direction(100).latitude(bdLocation.getLatitude())
                    .longitude(bdLocation.getLongitude()).build();
            mBaiduMap.setMyLocationData(locData);

            mMe.setLatitude(bdLocation.getLatitude());
            mMe.setLongitude(bdLocation.getLongitude());
            mMe.update(new UpdateListener() {
                @Override
                public void done(BmobException e) {
                    if (null == e) {
                        Log.i(TAG, "Me ===>>> Latitude : " + bdLocation.getLatitude() + ", Longitude : " + mLongitude);
                    }
                }
            });

            // 第一次定位时,将地图位置移动到当前位置
            if (firstLocation) {
                firstLocation = false;
                LatLng xy = new LatLng(bdLocation.getLatitude(),
                        bdLocation.getLongitude());
                MapStatusUpdate status = MapStatusUpdateFactory.newLatLng(xy);
                mBaiduMap.animateMapStatus(status);
            }

        }
    });

}
项目:mapsforge    文件:MapZoomControls.java   
ZoomControlsHideHandler(ZoomControls zoomControls) {
    super();
    this.zoomControls = zoomControls;
}
项目:AyoSunny    文件:GhostActivity.java   
protected ZoomControls findZoomControls(int id){return (ZoomControls)this.findViewById(id);}