首先感謝 PTT AndroidDev版的 kewang 大大分享的 Sample Code
使用筆記:
1. 請先到Google申請 Api Key:https://code.google.com/apis/console/
2. AndroidMainfest加入下面Code
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="你申請的Key" />
<!-- 權限 -->
<uses-permission android:name="tw.kewang.mapcontroller.samples.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
3. Marker要自訂Icon
MarkerOptions markerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_location));
4. 自訂Info Window
GoogleMap.InfoWindowAdapter adapter = new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
//實作你的view
return null;
}
@Override
public View getInfoContents(Marker arg0) {
//實作你的view
return null;
}
};
map.setInfoWindowAdapter(adapter);