百度导航Android版问题集
百度导航Android版问题集
软硬件环境
- Macbook Pro MGX 72
- Android Studio 1.4
- 酷比魔方7寸平板
- 百度导航SDK 3.0.0
运行导航Demo
首先还是常规路数,申请开发者账户,创建应用
Baidu Dev Center接下来去下载Demo工程,地址是http://lbsyun.baidu.com/sdk/download,这里最好是自己新建一个android工程,然后将demo中的相应文件拷贝到工程里去,因为在申请Key的过程中就需要用到包名。修改工程菜单文件AndroidManifest.xml文件,将申请的Key添加进去,重新运行工程,导航界面就出来了
Baidu Navi Demo UI“算路失败”
从网络上找到了2个地点的经纬度信息,(121.387211,31.088074)和(121.523014,31.277986),一个作为起始点,一个作为结束点,调用导航函数BNRoutePlanNode,提示”算路失败”的错误。后来发现实参的顺序是经度在前,纬度在后,调换下顺序就导航成功了
没有语音
在打开demo时,发现logcat里有句报错
bdTTSGetAuthorize failed!
这是因为SDK内置百度TTS语音播报功能,需要对app进行授权验证才能够使用,授权方法是http://developer.baidu.com/map/index.php?title=android-navsdk/guide/voice
离线地图
在百度地图SDK中提供的Demo中,有离线下载城市地图资源包的示例,使用默认路径,看看BaseMapDemo.java里的onCreate函数
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); if (intent.hasExtra("x") && intent.hasExtra("y")) { // 当用intent参数时,设置中心点为指定点 Bundle b = intent.getExtras(); LatLng p = new LatLng(b.getDouble("y"), b.getDouble("x")); mMapView = new MapView(this, new BaiduMapOptions().mapStatus(new MapStatus.Builder() .target(p).build())); } else { mMapView = new MapView(this, new BaiduMapOptions()); } setContentView(mMapView); mBaiduMap = mMapView.getMap(); }
当前一个activity没有传值(key值分别是x和y,对应经纬度信息)过来时,会默认显示北京的地图。知道了这点后,可以通过传值来更改默认的地图显示,如下示例
Bundle bundle = new Bundle();bundle.putDouble("y",31.088074);bundle.putDouble("x",121.387211);intent.putExtras(bundle);startActivity(intent);

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

OnLeaks has now partnered with Android Headlines to provide a first look at the Galaxy S25 Ultra, a few days after a failed attempt to generate upwards of $4,000 from his X (formerly Twitter) followers. For context, the render images embedded below h

Alongside announcing two new smartphones, TCL has also announced a new Android tablet called the NXTPAPER 14, and its massive screen size is one of its selling points. The NXTPAPER 14 features version 3.0 of TCL's signature brand of matte LCD panels

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

Samsung has not offered any hints yet about when it will update its Fan Edition (FE) smartphone series. As it stands, the Galaxy S23 FE remains the company's most recent edition, having been presented at the start of October 2023. However, plenty of

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

OnePlus'sister brand iQOO has a 2023-4 product cycle that might be nearlyover; nevertheless, the brand has declared that it is not done with itsZ9series just yet. Its final, and possibly highest-end,Turbo+variant has just beenannouncedas predicted. T
