日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

显示地图

發(fā)布時(shí)間:2023/12/18 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 显示地图 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

顯示地圖的全部代碼
-----------------xml中的代碼

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#f8f8ff"
android:orientation="vertical" >

<com.baidu.mapapi.map.TextureMapView
android:id="@+id/RegionalCoordinatesbRegionMap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" >
</com.baidu.mapapi.map.TextureMapView>

</LinearLayout>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class類中的代碼,其中包含多位置標(biāo)點(diǎn) 點(diǎn)擊標(biāo)點(diǎn)顯示提示文本框并在點(diǎn)擊文本框時(shí)執(zhí)行對(duì)應(yīng)的點(diǎn)擊事件

public class RegionalCoordinates extends Activity{

private BaiduMap baiduMap;
private TextureMapView mMapView;
private MapStatusUpdate msu ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.regional_coordinates);
mMapView = (TextureMapView) findViewById(R.id.RegionalCoordinatesbRegionMap);
init();
}
private void init() {
// TODO Auto-generated method stub
baiduMap = mMapView.getMap();
baiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
baiduMap.setTrafficEnabled(true);
// 設(shè)置初始加載位置
msu = MapStatusUpdateFactory.newLatLngZoom(new LatLng(24.800427,118.599943),13);
baiduMap.setMapStatus(msu);
List<OverlayOptions> options = new ArrayList<OverlayOptions>();
for (Map<String, Object> map : DatasStatistics.getRegionMap()) {
Map<String, Object> obj= (Map<String, Object>) map.get("datastatistics");
//構(gòu)建Marker圖標(biāo)
BitmapDescriptor bitmap;
//用來構(gòu)造InfoWindow

if(obj==null||(Double)obj.get("blockagedegree")>20){
bitmap = BitmapDescriptorFactory
.fromResource(R.drawable.exception);
}else{
bitmap = BitmapDescriptorFactory
.fromResource(R.drawable.yes);
}
//定義Maker坐標(biāo)點(diǎn)
LatLng point1 = new LatLng((Double) map.get("latitude"), (Double) map.get("longitude"));
//構(gòu)建MarkerOption,用于在地圖上添加Marker
OverlayOptions option1 = new MarkerOptions()
.position(point1)
.icon(bitmap);
options.add(option1);
}
baiduMap.addOverlays(options);
//獲取地圖標(biāo)記點(diǎn)擊事件
baiduMap.setOnMarkerClickListener(new OnMarkerClickListener() {
//加載標(biāo)點(diǎn)上方文本點(diǎn)擊事件
InfoWindow.OnInfoWindowClickListener listener = new InfoWindow.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick() {
Intent i = new Intent(RegionalCoordinates.this, SingleDetails.class);
startActivity(i);
overridePendingTransition(R.anim.fade_out,R.anim.fade_in);
}
};
//加載標(biāo)點(diǎn)點(diǎn)擊事件
@Override
public boolean onMarkerClick(Marker mak) {
//設(shè)置文本標(biāo)題
BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.tips);
LatLng latLng =mak.getPosition();
//設(shè)置參數(shù)為了得到詳情利用經(jīng)緯度
DatasStatistics.setLatLng(latLng);
//傳值顯示
InfoWindow mInfoWindow = new InfoWindow(bitmap, latLng, -30, listener);
baiduMap.showInfoWindow(mInfoWindow);
return false;
}
});
//在地圖上添加Marker,并顯示
}

@Override
protected void onDestroy() {
super.onDestroy();
//在activity執(zhí)行onDestroy時(shí)執(zhí)行mMapView.onDestroy(),實(shí)現(xiàn)地圖生命周期管理
mMapView.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
//在activity執(zhí)行onResume時(shí)執(zhí)行mMapView. onResume (),實(shí)現(xiàn)地圖生命周期管理
mMapView.onResume();
}
@Override
protected void onPause() {
super.onPause();
//在activity執(zhí)行onPause時(shí)執(zhí)行mMapView. onPause (),實(shí)現(xiàn)地圖生命周期管理
mMapView.onPause();
}
@Override
public void onBackPressed() {
Intent i = new Intent(RegionalCoordinates.this, TableDetails.class);
startActivity(i);
overridePendingTransition(R.anim.fade_out,R.anim.fade_in);
}
private long logOut =0;
private long lastClickTime=0;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
最終顯示效果

,利用經(jīng)緯度對(duì)通過url跳轉(zhuǎn)百度地圖

button.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
Uri uri = Uri.parse("http://api.map.baidu.com/geocoder?location="+
DatasStatistics.getLatLng().latitude+","+DatasStatistics.getLatLng().longitude+"&coord_type=bd09ll&output=html&src=webapp.baidu.openAPIdemo");

Intent intent = new Intent(Intent.ACTION_VIEW, uri);

startActivity(intent);
}
});
---------------------?

轉(zhuǎn)載于:https://www.cnblogs.com/hyhy904/p/11284669.html

總結(jié)

以上是生活随笔為你收集整理的显示地图的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。