开发者社区> 问答> 正文

Android使用百度map api写的地图,怎么定位自己位置并在进入界面显示?

使用的百度map api 但是定位每次都出现在天安门那里

代码 public void onLocationChanged(Location location) {

 // TODO Auto-generated method stub

 if (location != null) {

 GeoPoint geoPoint = new GeoPoint(

 (int) (location.getLatitude() * 1e6),

 (int) (location.getLongitude() * 1e6));

 mMapView.getController().animateTo(geoPoint);

 mMapController = mMapView.getController();

展开
收起
爵霸 2016-06-08 10:26:53 2644 0
1 条回答
写回答
取消 提交回答
  • 你好,我是使用百度地图api的新手,但是写出来的程序也只能定位到天安门,

    Location loc = new Location();
                 this.latitude = loc.getValueOfLatitude() * 1e6;
                 this.longtitude = loc.getValueOfLongtitde() * 1e6;
                 
                 GeoPoint point = new GeoPoint((int)latitude, (int) longtitude);
                 myMapView.getController().animateTo(point); 
    2019-07-17 19:31:18
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
CUDA MATH API 立即下载
API PLAYBOOK 立即下载
传统企业的“+互联网”-API服务在京东方的实践 立即下载