Java 类com.baidu.mapapi.map.LocationData 实例源码

项目:like_googleplus_layout    文件:LocationActivity.java   
public void onClickMapPoi(MapPoi poi)
{
    if (null != poi)
    {
        mEndGeoPoint = new GeoPoint(poi.geoPt.getLatitudeE6(), poi.geoPt.getLongitudeE6());
        LocationData clickLocationData = new LocationData();
        clickLocationData.latitude = poi.geoPt.getLatitudeE6() / 1000000.0;
        clickLocationData.longitude = poi.geoPt.getLongitudeE6() / 1000000.0;
        mClickLocationOverlay.setData(clickLocationData);
        mClickLocationOverlay.setMarker(getResources().getDrawable(R.drawable.ic_nav_turn_start_s));
        mMapView.getOverlays().remove(mClickLocationOverlay);
        // mMapView.getOverlays().add(mClickLocationOverlay);
        MKPoiInfo info = new MKPoiInfo();
        info.pt = poi.geoPt;
        info.address = poi.strText;
        routeDrive(info, true);
        mMapView.refresh();
        Toast.makeText(LocationActivity.this, poi.strText, Toast.LENGTH_SHORT).show();
    }
}
项目:FunWeibo    文件:BaiduMapActivity.java   
/**
 * 设置用户当前位置
 * @param p 要设置的位置,gcj坐标系
 */
private void setMyLocation(Position p) {
    if(p != null && p.isValid()) {
        //坐标转换
        GeoPoint gp = CoordinateConvert.fromGcjToBaidu(new GeoPos(p.getLat(), p.getLon()));
        //创建位置
        LocationData locData = new LocationData();
        locData.latitude = gp.getLatitudeE6() * 1.0 / 1E6;
        locData.longitude = gp.getLongitudeE6() * 1.0 / 1E6;
        locData.direction = p.getDirection();
        locData.accuracy = p.getRadius();
        locData.speed = p.getSpeed();
        //设置位置
        myLocationOverlay.setData(locData);
        if(!mMapView.getOverlays().contains(myLocationOverlay)) {
            mMapView.getOverlays().add(myLocationOverlay);
        } else {
            //KLog.d(TAG, "overlay added al-ready!");
        }
        mMapView.refresh();
    }
}
项目:itmarry    文件:MapActivity.java   
public void onReceiveLocation(BDLocation location) {
    if (sp != null) {
        Editor editor = sp.edit();
        editor.putFloat("Latitude", (float) location.getLatitude());
        editor.putFloat("Longitude", (float) location.getLongitude());
        if (!editor.commit()) {
            Toast.makeText(MapActivity.this, "����λ��ʧ��", 0).show();
        }
    }
    address = location.getDistrict();
    LocationData data = new LocationData();
    data.accuracy = location.getRadius();
    data.latitude = location.getLatitude();
    data.longitude = location.getLongitude();
    myLoc = new GeoPoint((int) (location.getLatitude() * 1e6),
            (int) (location.getLongitude() * 1e6));
    myLocation.setData(data);
    mMapView.refresh();
    mMapView.getController().animateTo(myLoc);
    if (MapActivity.this.location != null) {
        AnimationDrawable animdraw = (AnimationDrawable) MapActivity.this.location
                .getBackground();
        animdraw.stop();
        MapActivity.this.location
                .setBackgroundResource(R.drawable.btn_location);
        MapActivity.this.location.setClickable(true);
        if (!hasLocation) {
            g.showButton();
            hasLocation = !hasLocation;
        }
    }
    Toast.makeText(MapActivity.this,
            "��������λ���ǣ�" + location.getCity() + location.getDistrict(), 0)
            .show();
}
项目:itmarry    文件:PoiSelectActivity.java   
private void initLocationClient() {
    client = new LocationClient(getApplicationContext());
    MyApplication myapp = (MyApplication) this.getApplication();
    client.setAK(myapp.getKEK());// ���ö�λ�����KEY
    client.registerLocationListener(new BDLocationListener() {
        public void onReceivePoi(BDLocation arg0) {
        }

        public void onReceiveLocation(BDLocation res) {
            if (res != null) {
                LocationData data = new LocationData();
                data.latitude = res.getLatitude();
                data.longitude = res.getLongitude();
                data.accuracy = res.getRadius();
                MyLocationOverlay locationOverlay = new MyLocationOverlay(
                        map);
                GeoPoint poi = new GeoPoint(
                        (int) (res.getLatitude() * 1e6), (int) (res
                                .getLongitude() * 1e6));
                locationOverlay.setData(data);
                map.getOverlays().add(locationOverlay);
                map.refresh();
                map.getController().animateTo(poi);
                probar.setVisibility(View.GONE);
                flag.setVisibility(View.VISIBLE);
            }

        }
    });// ע�����
    LocationClientOption option = new LocationClientOption();// ���ö�λ����
    option.setAddrType("all");// ����������Ϣ
    option.disableCache(true);// �����涨λ��Ϣ
    option.setCoorType("bd09ll");// ���ص���������
    option.setTimeOut(8000);// ���ö�λ��ʱ
    client.setLocOption(option);// �������
    client.start();
}
项目:itmarry    文件:GetLbsTab.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    userInfo = this.getSharedPreferences("setting", Context.MODE_PRIVATE);
    global = Global.getInstance(userInfo.getString("dm_user", ""));
    //����SharedPreferences
    this.rwInfo=this.getSharedPreferences(this.getIntent().getIntExtra("rw_dm", 0)+"", Context.MODE_PRIVATE);
    setContentView(R.layout.activity_get_lbs_tab);

    // ��ͼ��ʼ��
    mMapView = (MapView) findViewById(R.id.bmapsView);
    mMapController = mMapView.getController();
    mMapView.getController().setZoom(18);
    mMapView.getController().enableClick(true);
    mMapView.setBuiltInZoomControls(true);
    // ���� ��������ͼ��
    createPaopao();

    // ��λ��ʼ��
    mLocClient = new LocationClient(this);
    locData = new LocationData();
    mLocClient.registerLocationListener(myListener);
    mLocClient.setAK(Utils.getMetaValue(getApplication(), "map_api_key"));
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// ��gps
    option.setCoorType("bd09ll"); // ������������
    option.setScanSpan(1000);
    option.setAddrType("all");
    mLocClient.setLocOption(option);
    mLocClient.start();
    // ��λͼ���ʼ��
    myLocationOverlay = new locationOverlay(mMapView);
    // ���ö�λ����
    myLocationOverlay.setData(locData);
    // ��Ӷ�λͼ��
    mMapView.getOverlays().add(myLocationOverlay);
    myLocationOverlay.enableCompass();
    // �޸Ķ�λ���ݺ�ˢ��ͼ����Ч
    mMapView.refresh();
}
项目:calltaxi    文件:MapActivity.java   
public void addSelfOverlay(double Lati, double Long) {
    myLocationOverlay = new MyLocationOverlay(mMapView);
    LocationData locData = new LocationData();
    locData.latitude = Lati;
    locData.longitude = Long;
    myLocationOverlay.setData(locData);
    mMapView.getOverlays().add(myLocationOverlay);
    mMapView.refresh();
    mMapView.getController().animateTo(new GeoPoint((int)( locData.latitude * 1e6),(int)(locData.longitude * 1e6)));
}
项目:calltaxi    文件:MapActivity.java   
public void onReceiveLocation(BDLocation location) {
         if (location == null)
                 return ;
         StringBuffer sb = new StringBuffer(256);
         sb.append("time : ");
         sb.append(location.getTime());
         sb.append("\nerror code : ");
         sb.append(location.getLocType());
         sb.append("\nlatitude : ");
         sb.append(location.getLatitude());
         sb.append("\nlontitude : ");
         sb.append(location.getLongitude());
         sb.append("\nradius : ");
         sb.append(location.getRadius());
         if (location.getLocType() == BDLocation.TypeGpsLocation){
                 sb.append("\nspeed : ");
                 sb.append(location.getSpeed());
                 sb.append("\nsatellite : ");
                 sb.append(location.getSatelliteNumber());
         } 
         else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
                 sb.append("\naddr : ");
                 sb.append(location.getAddrStr());
         }

         if(false == move) {
             addSelfOverlay(location.getLatitude() ,location.getLongitude());
             move = true;
         }
         else {
             LocationData locData = new LocationData();
             locData.latitude = location.getLatitude();
             locData.longitude = location.getLongitude();
             locData.direction = location.getDirection();
             myLocationOverlay.setData(locData);
         }
        mMapView.refresh();
}
项目:calltaxi    文件:MapActivity.java   
public void addSelfOverlay(double Lati, double Long) {
    myLocationOverlay = new MyLocationOverlay(mMapView);
    LocationData locData = new LocationData();
    locData.latitude = Lati;
    locData.longitude = Long;
    myLocationOverlay.setData(locData);
    mMapView.getOverlays().add(myLocationOverlay);
    mMapView.refresh();
    mMapView.getController().animateTo(new GeoPoint((int)( locData.latitude * 1e6),(int)(locData.longitude * 1e6)));
}
项目:NeXT_pyp    文件:BMapLocActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 初始化
    initEngineManager(this);


    // 布局获取ID
    setContentView(R.layout.pyp_page_map);
    mMapView = (MapView) findViewById(R.id.bmapView);

     //实例化监听事件
       mMapView.regMapViewListener(mBMapManager, mMapListener);
       mMapView.regMapTouchListner(mapTouchListener);

       //实例化工具
       myLocationOverlay = new MyLocationOverlay(mMapView);
       mLocClient = new LocationClient(this.getApplicationContext());       
    option = new LocationClientOption();
       myListener = new MyLocationListenner();
       locData = new LocationData();

       mLocClient.setAK(APPCodeConst.ak);
       mLocClient.registerLocationListener(myListener); 
       mLocClient.start();
       mLocClient.requestLocation();
       //对应方法
       setOption();

}
项目:NeXT_pyp    文件:BMapLocActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 初始化
    initEngineManager(this);


    // 布局获取ID
    setContentView(R.layout.pyp_page_map);
    mMapView = (MapView) findViewById(R.id.bmapView);

     //实例化监听事件
       mMapView.regMapViewListener(mBMapManager, mMapListener);
       mMapView.regMapTouchListner(mapTouchListener);

       //实例化工具
       myLocationOverlay = new MyLocationOverlay(mMapView);
       mLocClient = new LocationClient(this.getApplicationContext());       
    option = new LocationClientOption();
       myListener = new MyLocationListenner();
       locData = new LocationData();

       mLocClient.setAK(APPCodeConst.ak);
       mLocClient.registerLocationListener(myListener); 
       mLocClient.start();
       mLocClient.requestLocation();
       //对应方法
       setOption();

}
项目:p1-android    文件:VenueActivity.java   
private void setMyLocationOverlay() {
    MyLocationOverlay locationOverlay = new MyLocationOverlay(mMapView);
    LocationData locdata = new LocationData();
    locdata.latitude = mLastLocation.getLatitude();
    locdata.longitude = mLastLocation.getLongitude();
    locdata.direction = 0.0f;
    locationOverlay.setData(locdata);
    mMapView.getOverlays().add(locationOverlay);
    mMapView.refresh();
    mMapView.getController().animateTo(
            Utils.LocationDataToGeoPoint(locdata));
}
项目:FunWeibo    文件:BaiduMapActivity.java   
/**
 * 地图动画移动到我的位置
 */
private void spanToMyLocation() {
    if(myLocationOverlay != null) {
        LocationData data = myLocationOverlay.getMyLocation();
        GeoPos point = new GeoPos(data.latitude, data.longitude);
        mMapView.getController().animateTo(point);
    }
}
项目:itmarry    文件:LjghTab.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_map);

    mMapView = (MapView) findViewById(R.id.bmapsView);
    mMapView.setBuiltInZoomControls(true);
    // mMapView.setSatellite(true);
    // �����������õ����ſؼ�
    mMapController = mMapView.getController();
    // �õ�mMapView�Ŀ���Ȩ,�����������ƺ�����ƽ�ƺ�����
    locData = new LocationData();
    locData.direction = 2.0f;

    Intent intent = this.getIntent();
    this.jd=intent.getDoubleExtra("jd", 0);
    this.wd=intent.getDoubleExtra("wd", 0);

    // ��ȡ���������
    Log.d("wd", jd + "");
    Log.d("jd", wd + "");
    locData.latitude = wd;
    locData.longitude = jd;
    myLocationOverlay = new MyLocationOverlay(mMapView);

    myLocationOverlay.setData(locData);
    GeoPoint point = new GeoPoint((int) (locData.latitude * 1e6),
            (int) (locData.longitude * 1e6));
    // �ø����ľ�γ�ȹ���һ��GeoPoint����λ��΢�� (�� * 1E6)
    mMapController.setCenter(point);// ���õ�ͼ���ĵ�
    mMapController.setZoom(18);// ���õ�ͼzoom����
    mMapView.getOverlays().add(myLocationOverlay);
    mMapView.refresh();
    mMapView.getController().animateTo(point);

    // ��ʼ��ȡ��ǰλ������

    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    mLocClient.setAK(Utils.getMetaValue(getApplication(), "map_api_key"));
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// ��gps
    option.setCoorType("bd09ll"); // ������������
    option.setScanSpan(1000);
    option.setAddrType("all");
    mLocClient.setLocOption(option);

    mLocClient.start();
}
项目:itmarry    文件:DaoHangTab.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    userInfo = this.getSharedPreferences("setting", Context.MODE_PRIVATE);
    global = Global.getInstance(userInfo.getString("dm_user", ""));
    // ����SharedPreferences
    this.rwInfo = this.getSharedPreferences(
            this.getIntent().getIntExtra("rw_dm", 0) + "",
            Context.MODE_PRIVATE);
    setContentView(R.layout.activity_get_lbs_tab);

    // ��ͼ��ʼ��
    mMapView = (MapView) findViewById(R.id.bmapsView);
    mMapController = mMapView.getController();
    mMapView.getController().setZoom(18);
    mMapView.getController().enableClick(true);
    mMapView.setBuiltInZoomControls(true);
    // ���� ��������ͼ��
    createPaopao();

    // ��λ��ʼ��
    mLocClient = new LocationClient(this);
    locData = new LocationData();
    mLocClient.registerLocationListener(myListener);
    mLocClient.setAK(Utils.getMetaValue(getApplication(), "map_api_key"));
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// ��gps
    option.setCoorType("bd09ll"); // ������������
    option.setScanSpan(1000);
    option.setAddrType("all");
    mLocClient.setLocOption(option);
    mLocClient.start();
    // ��λͼ���ʼ��
    myLocationOverlay = new locationOverlay(mMapView);
    // ���ö�λ����
    myLocationOverlay.setData(locData);
    // ��Ӷ�λͼ��
    mMapView.getOverlays().add(myLocationOverlay);
    myLocationOverlay.enableCompass();
    // �޸Ķ�λ���ݺ�ˢ��ͼ����Ч
    mMapView.refresh();
}
项目:calltaxi    文件:MapActivity.java   
public void onReceiveLocation(BDLocation location) {
         if (location == null)
                 return ;
         StringBuffer sb = new StringBuffer(256);
         sb.append("time : ");
         sb.append(location.getTime());
         sb.append("\nerror code : ");
         sb.append(location.getLocType());
         sb.append("\nlatitude : ");
         sb.append(location.getLatitude());
         sb.append("\nlontitude : ");
         sb.append(location.getLongitude());
         sb.append("\nradius : ");
         sb.append(location.getRadius());
         if (location.getLocType() == BDLocation.TypeGpsLocation){
                 sb.append("\nspeed : ");
                 sb.append(location.getSpeed());
                 sb.append("\nsatellite : ");
                 sb.append(location.getSatelliteNumber());
         } 
         else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
                 sb.append("\naddr : ");
                 sb.append(location.getAddrStr());
         }

         if(false == move) {
             addSelfOverlay(location.getLatitude() ,location.getLongitude());
             move = true;
         }
         else {
             LocationData locData = new LocationData();
             locData.latitude = location.getLatitude();
             locData.longitude = location.getLongitude();
             locData.direction = location.getDirection();
             myLocationOverlay.setData(locData);
         }
        mMapView.refresh();
        HttpFunc web = new HttpFunc();
        String url = prefix + "updatePos.php?id=" + app.id + "&lait=" + location.getLatitude();
        url = url + "&long=" + location.getLongitude();
        if(true == isWork())
            web.execute(url);
}
项目:p1-android    文件:Utils.java   
public static GeoPoint LocationDataToGeoPoint(LocationData ld) {
    return new GeoPoint((int) (ld.latitude * 1E6),
            (int) (ld.longitude * 1E6));
}
项目:YikuairAndroid    文件:LocationChangeListener.java   
/**
 * 定位变化的位置回调
 *
 * @param locData
 * @see com.baidu.baidumaps.api.location.LocationManager.LocData
 */
public abstract void onLocationChange(LocationData locData);