package com.baidu.mapapi.demo;
import java.util.ArrayList;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.MKOLSearchRecord;
import com.baidu.mapapi.MKOLUpdateElement;
import com.baidu.mapapi.MKOfflineMap;
import com.baidu.mapapi.MKOfflineMapListener;
import com.baidu.mapapi.MapActivity;
import com.baidu.mapapi.MapView;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class OfflineDemo extends MapActivity implements MKOfflineMapListener {
private MapView mMapView = null;
private MKOfflineMap mOffline = null;
private EditText mEditCityName;
private EditText mEditCityId;
private TextView mText;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.offline);
BMapApiDemoApp app = (BMapApiDemoApp)this.getApplication();
if (app.mBMapMan == null) {
app.mBMapMan = new BMapManager(getApplication());
app.mBMapMan.init(app.mStrKey, new BMapApiDemoApp.MyGeneralListener());
}
app.mBMapMan.start();
super.initMapActivity(app.mBMapMan);
mMapView = (MapView)findViewById(R.id.bmapView);
mMapView.setBuiltInZoomControls(true);
mOffline = new MKOfflineMap();
mOffline.init(app.mBMapMan, this);
ArrayList<MKOLUpdateElement> info = mOffline.getAllUpdateInfo();
if (info != null) {
Log.d("OfflineDemo", String.format("has %d city info", info.size()));
if (info.get(0).status == MKOLUpdateElement.FINISHED) {
}
}
ArrayList<MKOLSearchRecord> records = mOffline.getHotCityList();
if (records != null) {
Log.d("OfflineDemo", String.format("has %d hot city", records.size()));
}
mEditCityName = (EditText)findViewById(R.id.city);
mEditCityId = (EditText)findViewById(R.id.cityid);
mText = (TextView)findViewById(R.id.text);
Button btn = (Button)findViewById(R.id.start);
btn.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
int cityid = -1;
try {
cityid = Integer.parseInt(mEditCityId.getText().toString());
} catch (Exception e) {
}
if (mOffline.start(cityid)) {
Log.d("OfflineDemo", String.format("start cityid:%d", cityid));
} else {
Log.d("OfflineDemo", String.format("not start cityid:%d", cityid));
}
}
});
btn = (Button)findViewById(R.id.stop);
btn.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
int cityid = -1;
try {
cityid = Integer.parseInt(mEditCityId.getText().toString());
} catch (Exception e) {
}
if (mOffline.pause(cityid)) {
Log.d("OfflineDemo", String.format("stop cityid:%d", cityid));
} else {
Log.d("OfflineDemo", String.format("not pause cityid:%d", cityid));
}
}
});
btn = (Button)findViewById(R.id.search);
btn.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
ArrayList<MKOLSearchRecord> records = mOffline.searchCity(mEditCityName.getText().toString());
if (records == null || records.size() != 1)
return;
mEditCityId.setText(String.valueOf(records.get(0).cityID));
}
});
btn = (Button)findViewById(R.id.del);
btn.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
int cityid = -1;
try {
cityid = Integer.parseInt(mEditCityId.getText().toString());
} catch (Exception e) {
}
if (mOffline.remove(cityid)) {
Log.d("OfflineDemo", String.format("del cityid:%d", cityid));
} else {
Log.d("OfflineDemo", String.format("not del cityid:%d", cityid));
}
}
});
btn = (Button)findViewById(R.id.scan);
btn.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
int num = mOffline.scan();
if (num != 0)
mText.setText(String.format("已安装%d个离线包", num));
Log.d("OfflineDemo", String.format("scan offlinemap num:%d", num));
}
});
btn = (Button)findViewById(R.id.get);
btn.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
int cityid = -1;
try {
cityid = Integer.parseInt(mEditCityId.getText().toString());
} catch (Exception e) {
}
MKOLUpdateElement element = mOffline.getUpdateInfo(cityid);
if (element != null) {
new AlertDialog.Builder(OfflineDemo.this)
.setTitle(element.cityName)
.setMessage(String.format("大小:%.2fMB 已下载%d%%", ((double)element.size)/1000000, element.ratio))
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
}
}).show();
}
}
});
}
@Override
protected void onPause() {
BMapApiDemoApp app = (BMapApiDemoApp)this.getApplication();
app.mBMapMan.stop();
super.onPause();
}
@Override
protected void onResume() {
BMapApiDemoApp app = (BMapApiDemoApp)this.getApplication();
app.mBMapMan.start();
super.onResume();
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
@Override
public void onGetOfflineMapState(int type, int state) {
switch (type) {
case MKOfflineMap.TYPE_DOWNLOAD_UPDATE:
{
Log.d("OfflineDemo", String.format("cityid:%d update", state));
MKOLUpdateElement update = mOffline.getUpdateInfo(state);
mText.setText(String.format("%s : %d%%", update.cityName, update.ratio));
}
break;
case MKOfflineMap.TYPE_NEW_OFFLINE:
Log.d("OfflineDemo", String.format("add offlinemap num:%d", state));
break;
case MKOfflineMap.TYPE_VER_UPDATE:
Log.d("OfflineDemo", String.format("new offlinemap ver"));
break;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
小程序 百度地图API源码.rar
共93个文件
class:35个
png:25个
java:11个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 10 浏览量
2023-02-03
11:42:07
上传
评论
收藏 1.59MB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序 百度地图API源码.rar (93个子文件)
Android 百度地图API源码
project.properties 360B
.classpath 502B
.settings
org.eclipse.jdt.core.prefs 629B
assets
src
com
baidu
mapapi
demo
RoutePlan.java 6KB
BMapApiDemoMain.java 3KB
MapViewDemo.java 1KB
PoiSearch.java 4KB
BMapApiDemoApp.java 2KB
GeoCoder.java 6KB
MyLocation.java 2KB
OfflineDemo.java 6KB
LocationOverlay.java 3KB
ItemizedOverlayDemo.java 6KB
libs
armeabi
libBMapApiEngine.so 1.22MB
baidumapapi.jar 214KB
lint.xml 53B
res
drawable-mdpi
iconmarka.png 867B
pop.png 1KB
icon.png 3KB
drawable-ldpi
iconmarka.png 867B
pop.png 1KB
icon.png 2KB
values
strings.xml 181B
layout
mapviewdemo.xml 373B
offline.xml 2KB
geocoder.xml 1KB
main.xml 564B
popview.xml 470B
routeplan.xml 1KB
poisearch.xml 1KB
mylocation.xml 412B
drawable
iconmarka.png 867B
pop.png 1KB
icon.png 3KB
drawable-hdpi
iconmarka.png 867B
pop.png 1KB
icon.png 4KB
bin
classes
com
baidu
mapapi
demo
OfflineDemo$4.class 2KB
BMapApiDemoApp.class 1KB
MapViewDemo.class 2KB
BMapApiDemoMain$1.class 1KB
OfflineDemo$3.class 2KB
OverItemT.class 4KB
RoutePlan$1.class 3KB
MyLocation$1.class 1KB
OfflineDemo$1.class 2KB
MyLocation.class 2KB
LocationOverlay$1.class 1KB
R$string.class 436B
RoutePlan.class 4KB
R$layout.class 632B
ItemizedOverlayDemo.class 3KB
RoutePlan$2.class 810B
R$id.class 1KB
PoiSearch$2.class 810B
PoiSearch$1.class 3KB
GeoCoder$OverItemT.class 2KB
OfflineDemo$5.class 2KB
PoiSearch.class 3KB
R$attr.class 349B
BMapApiDemoApp$MyGeneralListener.class 1KB
GeoCoder$2.class 804B
OfflineDemo$6$1.class 875B
R$drawable.class 469B
BMapApiDemoMain.class 4KB
OfflineDemo$6.class 3KB
LocationOverlay.class 3KB
R.class 552B
OfflineDemo.class 5KB
GeoCoder$1.class 4KB
GeoCoder.class 3KB
OfflineDemo$2.class 2KB
resources.ap_ 32KB
res
drawable-mdpi
iconmarka.png 1KB
pop.png 2KB
icon.png 2KB
drawable-ldpi
iconmarka.png 1KB
pop.png 2KB
icon.png 2KB
drawable
iconmarka.png 1KB
pop.png 2KB
icon.png 2KB
drawable-hdpi
iconmarka.png 1KB
pop.png 2KB
icon.png 4KB
classes.dex 122KB
BaiduMapApiDemo.apk 764KB
proguard.cfg 1KB
default.properties 36B
.project 847B
AndroidManifest.xml 3KB
gen
com
baidu
mapapi
demo
R.java 2KB
1-120Q92105140-L.png 97KB
共 93 条
- 1
资源评论
大富大贵7
- 粉丝: 389
- 资源: 8868
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功