歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android中調用高德地圖的自定義標記視圖

Android中調用高德地圖的自定義標記視圖

日期:2017/3/1 9:55:36   编辑:Linux編程

1、在api中的MarkerDemoActivity是標記類,先初始化Amap對象init()、setUpMap(),再去定位(定位可以仿高德的api,也可以查查Android自帶的定位方法)

2、得到經緯度後,在獲取需要標記的坐標,在drawMarkers()裡添加需要標記的點

aMap.addMarker(new MarkerOptions().position(mList.get(i)).snippet(myFans.get(i).getNickname()).icon(BitmapDescriptorFactory.defaultMarker()));

3、可以設置窗口模式,再點擊標記後自動回調getInfoWindow()、getInfoContents(),如果需要自定義顯示圖像可以在這兩個方法裡調用render(marker, mWindow);,同時需要在CustomInfoWindowAdapter()裡加入需要顯示的布局view CustomInfoWindowAdapter() {

mWindow = getLayoutInflater().inflate(R.layout.custom_info_window, null);

mContents = getLayoutInflater().inflate(R.layout.custom_info_contents, null);

// mOptions = (RadioGroup)

// findViewById(R.id.custom_info_window_options);

}

在render方法裡處理標記提示信息具體的內容,包括顯示人名、點擊事件等等。

更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11

Copyright © Linux教程網 All Rights Reserved