2. OUTLINE
? 課程目標與進度
? Google map API key
? Google map API 介紹與使用
? Google map API 事件與
FrameLayout
? Google map API UI
? Google map API 绘製线
? 目前问题汇整
? 實作:Google map 與GPS感測
器互動
? Q&A
45. 45Presented By: Duran Hsieh
GOOGLE MAP API 绘製线
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng taiwan = new LatLng(23.97, 120.98);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(taiwan, 8));
mMutablePolyline = mMap.addPolyline(new PolylineOptions()
.add(A, B, C, D)
.width(5)
.color(Color.BLUE)
.clickable(true));
mMap.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
@Override
public void onPolylineClick(Polyline polyline) {
polyline.setColor(polyline.getColor() ^ 0x00ffffff);
}
});
}
Step 1. 加入屬性(點、線寬、顏色、點擊)
Step 1. 加入點擊事件
46. 46Presented By: Duran Hsieh
GOOGLE MAP API 绘製线
? AndroidGoogleMapPolylineExample:
? https://github.com/matsurigoto/AndroidGoogleMapPolyli
neExample.git
49. 49Presented By: Duran Hsieh
目前问题汇整
? 如何找 DEBUG ?
Step 1.
Set Break point
Step 2.Debug Step 3.Next Step
50. 50Presented By: Duran Hsieh
目前问题汇整
? 問題一 Error:Tag <uses-permission> attribute name
has invalid character ' '.
51. 51Presented By: Duran Hsieh
目前问题汇整
? 問題二 Attempt to invoke virtual method ‘android.view.Window$Callback
android.view.Window.getCallback()' on a null object reference
#35: public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney and move the camera LatLng sydney = new LatLng(-34, 151); mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));}
#41: Google map 官方有提供範例可以參考https://github.com/googlemaps/android-samples
#45: Note: Insert your picture by clicking on the Picture Place Holder Icon, then send it back!